Skip to content

Commit dad16c2

Browse files
zmoogmergify[bot]
authored andcommitted
[azure-eventhub] Update input v1 status on start, failure, and stop (#41469)
Update the Elastic Agent status by calling `inputContext.UpdateStatus(status.Failed, err.Error())` during the main input lifecycle phases (set up and run). If any setup, startup, and run steps fail, the input reports the fatal issue before shutting down. Without reporting the fatal error, the input logs the error and stops, but users continue to see it as "healthy" in Fleet, causing confusion and making troubleshooting much harder. (cherry picked from commit 882c854)
1 parent ec6866a commit dad16c2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
169169
- Improve modification time handling for entities and entity deletion logic in the Active Directory entityanalytics input. {pull}41179[41179]
170170
- Journald input now can read events from all boots {issue}41083[41083] {pull}41244[41244]
171171
- Fix errors in SQS host resolution in the `aws-s3` input when using custom (non-AWS) endpoints. {pull}41504[41504]
172+
- The azure-eventhub input now correctly reports its status to the Elastic Agent on fatal errors {pull}41469[41469]
172173

173174
*Heartbeat*
174175

x-pack/filebeat/input/azureeventhub/v1_input.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
v2 "github.com/elastic/beats/v7/filebeat/input/v2"
2424
"github.com/elastic/beats/v7/libbeat/beat"
2525
"github.com/elastic/beats/v7/libbeat/common/acker"
26+
"github.com/elastic/beats/v7/libbeat/management/status"
2627
"github.com/elastic/elastic-agent-libs/logp"
2728
"github.com/elastic/elastic-agent-libs/mapstr"
2829
)
@@ -68,9 +69,13 @@ func (in *eventHubInputV1) Run(
6869
) error {
6970
var err error
7071

72+
// Update the status to starting
73+
inputContext.UpdateStatus(status.Starting, "")
74+
7175
// Create pipelineClient for publishing events.
7276
in.pipelineClient, err = createPipelineClient(pipeline)
7377
if err != nil {
78+
inputContext.UpdateStatus(status.Failed, err.Error())
7479
return fmt.Errorf("failed to create pipeline pipelineClient: %w", err)
7580
}
7681
defer in.pipelineClient.Close()
@@ -82,6 +87,7 @@ func (in *eventHubInputV1) Run(
8287
// Set up new and legacy sanitizers, if any.
8388
sanitizers, err := newSanitizers(in.config.Sanitizers, in.config.LegacySanitizeOptions)
8489
if err != nil {
90+
inputContext.UpdateStatus(status.Failed, err.Error())
8591
return fmt.Errorf("failed to create sanitizers: %w", err)
8692
}
8793

@@ -98,16 +104,20 @@ func (in *eventHubInputV1) Run(
98104
// in preparation for the main run loop.
99105
err = in.setup(ctx)
100106
if err != nil {
107+
in.log.Errorw("error setting up input", "error", err)
108+
inputContext.UpdateStatus(status.Failed, err.Error())
101109
return err
102110
}
103111

104112
// Start the main run loop
105113
err = in.run(ctx)
106114
if err != nil {
107115
in.log.Errorw("error running input", "error", err)
116+
inputContext.UpdateStatus(status.Failed, err.Error())
108117
return err
109118
}
110119

120+
inputContext.UpdateStatus(status.Stopping, "")
111121
return nil
112122
}
113123

0 commit comments

Comments
 (0)