Skip to content

Commit

Permalink
Set agent.id to Fleet Agent ID for each metric/log monitoring input (#…
Browse files Browse the repository at this point in the history
…26776)

An earlier commit #26548 set the same value using a single global processor,
but that doesn't seem to make it into the final config so it had no effect. So this
sets the agent.id at the same places where elastic_agent.id is added.

(cherry picked from commit aa62bba)
  • Loading branch information
andrewkroh authored and mergify-bot committed Jul 12, 2021
1 parent 8586e1f commit 4749014
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
},
},
},
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
{
"drop_fields": map[string]interface{}{
"fields": []string{
Expand Down Expand Up @@ -319,6 +327,14 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
},
},
},
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
{
"drop_fields": map[string]interface{}{
"fields": []string{
Expand All @@ -339,16 +355,6 @@ 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(),
},
},
},
},
}

return result, true
Expand Down Expand Up @@ -398,6 +404,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
},
},
},
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
},
}, map[string]interface{}{
"module": "http",
Expand Down Expand Up @@ -437,6 +451,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
},
},
},
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
{
"copy_fields": map[string]interface{}{
"fields": []map[string]interface{}{
Expand Down Expand Up @@ -520,6 +542,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
},
},
},
{
"add_fields": map[string]interface{}{
"target": "agent",
"fields": map[string]interface{}{
"id": o.agentInfo.AgentID(),
},
},
},
{
"copy_fields": map[string]interface{}{
"fields": []map[string]interface{}{
Expand Down Expand Up @@ -571,16 +601,6 @@ 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(),
},
},
},
},
}

return result, true
Expand Down

0 comments on commit 4749014

Please sign in to comment.