Skip to content

Commit bb01339

Browse files
mergify[bot]zmoog
andauthored
[8.15](backport #41469) [azure-eventhub] Update input v1 status on start, failure, and stop (#41545)
* [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) * Drop unintentional changelog entries --------- Co-authored-by: Maurizio Branca <[email protected]>
1 parent aef85fe commit bb01339

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.next.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
102102
- Log bad handshake details when websocket connection fails {pull}41300[41300]
103103
- Improve modification time handling for entities and entity deletion logic in the Active Directory entityanalytics input. {pull}41179[41179]
104104
- Fix double encoding of client_secret in the Entity Analytics input's Azure Active Directory provider {pull}41393[41393]
105+
- The azure-eventhub input now correctly reports its status to the Elastic Agent on fatal errors {pull}41469[41469]
105106

106107
*Heartbeat*
107108

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

+10
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)