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
An earlier commit elastic#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.
  • Loading branch information
andrewkroh committed Jul 7, 2021
1 parent c64a11c commit cc2093e
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 cc2093e

Please sign in to comment.