From aa62bbaa4defc55eb363567b12676b7dc6889bf3 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Mon, 12 Jul 2021 13:16:42 -0400 Subject: [PATCH] Set agent.id to Fleet Agent ID for each metric/log monitoring input (#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. --- .../pkg/agent/operation/monitoring.go | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/x-pack/elastic-agent/pkg/agent/operation/monitoring.go b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go index 07491cbd6ab..14f26989cf2 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/monitoring.go +++ b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go @@ -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{ @@ -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{ @@ -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 @@ -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", @@ -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{}{ @@ -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{}{ @@ -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