Skip to content

Commit cc2093e

Browse files
committed
Set agent.id to Fleet Agent ID for each metric/log monitoring input
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.
1 parent c64a11c commit cc2093e

1 file changed

Lines changed: 40 additions & 20 deletions

File tree

x-pack/elastic-agent/pkg/agent/operation/monitoring.go

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
264264
},
265265
},
266266
},
267+
{
268+
"add_fields": map[string]interface{}{
269+
"target": "agent",
270+
"fields": map[string]interface{}{
271+
"id": o.agentInfo.AgentID(),
272+
},
273+
},
274+
},
267275
{
268276
"drop_fields": map[string]interface{}{
269277
"fields": []string{
@@ -319,6 +327,14 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
319327
},
320328
},
321329
},
330+
{
331+
"add_fields": map[string]interface{}{
332+
"target": "agent",
333+
"fields": map[string]interface{}{
334+
"id": o.agentInfo.AgentID(),
335+
},
336+
},
337+
},
322338
{
323339
"drop_fields": map[string]interface{}{
324340
"fields": []string{
@@ -339,16 +355,6 @@ func (o *Operator) getMonitoringFilebeatConfig(outputType string, output interfa
339355
"output": map[string]interface{}{
340356
outputType: output,
341357
},
342-
"processors": []map[string]interface{}{
343-
{
344-
"add_fields": map[string]interface{}{
345-
"target": "agent",
346-
"fields": map[string]interface{}{
347-
"id": o.agentInfo.AgentID(),
348-
},
349-
},
350-
},
351-
},
352358
}
353359

354360
return result, true
@@ -398,6 +404,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
398404
},
399405
},
400406
},
407+
{
408+
"add_fields": map[string]interface{}{
409+
"target": "agent",
410+
"fields": map[string]interface{}{
411+
"id": o.agentInfo.AgentID(),
412+
},
413+
},
414+
},
401415
},
402416
}, map[string]interface{}{
403417
"module": "http",
@@ -437,6 +451,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
437451
},
438452
},
439453
},
454+
{
455+
"add_fields": map[string]interface{}{
456+
"target": "agent",
457+
"fields": map[string]interface{}{
458+
"id": o.agentInfo.AgentID(),
459+
},
460+
},
461+
},
440462
{
441463
"copy_fields": map[string]interface{}{
442464
"fields": []map[string]interface{}{
@@ -520,6 +542,14 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
520542
},
521543
},
522544
},
545+
{
546+
"add_fields": map[string]interface{}{
547+
"target": "agent",
548+
"fields": map[string]interface{}{
549+
"id": o.agentInfo.AgentID(),
550+
},
551+
},
552+
},
523553
{
524554
"copy_fields": map[string]interface{}{
525555
"fields": []map[string]interface{}{
@@ -571,16 +601,6 @@ func (o *Operator) getMonitoringMetricbeatConfig(outputType string, output inter
571601
"output": map[string]interface{}{
572602
outputType: output,
573603
},
574-
"processors": []map[string]interface{}{
575-
{
576-
"add_fields": map[string]interface{}{
577-
"target": "agent",
578-
"fields": map[string]interface{}{
579-
"id": o.agentInfo.AgentID(),
580-
},
581-
},
582-
},
583-
},
584604
}
585605

586606
return result, true

0 commit comments

Comments
 (0)