Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fleet agent.id to Agent monitoring data #26548

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
- Log output of container to $LOGS_PATH/elastic-agent-start.log when LOGS_PATH set {pull}25150[25150]
- Use `filestream` input for internal log collection. {pull}25660[25660]
- Enable agent to send custom headers to kibana/ES {pull}26275[26275]
- Set `agent.id` to the Fleet Agent ID in events published from inputs backed by Beats. {issue}21121[21121] {pull}26394[26394]
- Set `agent.id` to the Fleet Agent ID in events published from inputs backed by Beats. {issue}21121[21121] {pull}26394[26394] {pull}26548[26548]
- Add proxy support to artifact downloader and communication with fleet server. {pull}25219[25219]
- Enable configuring monitoring namespace {issue}26439[26439]
- Communicate with Fleet Server over HTTP2. {pull}26474[26474]
20 changes: 20 additions & 0 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
"output": map[string]interface{}{
outputType: output,
},
"processors": []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, why is this processor not part of the input processors above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could go there, but by putting here it should be automatically applied to every input. In effect the processor is appended to the list of each input's processors. This way just means less code duplication.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently in the config transformation the root processors is dropped or not carried over to the final config so that didn't work. I opened #26776 to move add_fields into each input.

},
},
},
},
}

o.logger.Debugf("monitoring configuration generated for filebeat: %v", result)
Expand Down Expand Up @@ -563,6 +573,16 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
"output": map[string]interface{}{
outputType: output,
},
"processors": []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
},
}

o.logger.Debugf("monitoring configuration generated for metricbeat: %v", result)
Expand Down