@@ -51,6 +51,9 @@ const (
51
51
defaultMonitoringNamespace = "default"
52
52
agentName = "elastic-agent"
53
53
54
+ monitoringMetricsUnitID = "metrics-monitoring"
55
+ monitoringFilesUnitsID = "filestream-monitoring"
56
+
54
57
windowsOS = "windows"
55
58
56
59
// metricset execution period used for the monitoring metrics inputs
@@ -301,7 +304,7 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components []
301
304
302
305
streams := []interface {}{
303
306
map [string ]interface {}{
304
- idKey : "filestream-monitoring- agent" ,
307
+ idKey : fmt . Sprintf ( "%s- agent", monitoringFilesUnitsID ) ,
305
308
"type" : "filestream" ,
306
309
"paths" : []interface {}{
307
310
filepath .Join (logsDrop , agentName + "-*.ndjson" ),
@@ -439,7 +442,7 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components []
439
442
fixedBinaryName := strings .ReplaceAll (strings .ReplaceAll (comp .InputSpec .BinaryName , "-" , "_" ), "/" , "_" ) // conform with index naming policy
440
443
dataset := fmt .Sprintf ("elastic_agent.%s" , fixedBinaryName )
441
444
streams = append (streams , map [string ]interface {}{
442
- idKey : fmt .Sprintf ("filestream-monitoring- %s" , comp .ID ),
445
+ idKey : fmt .Sprintf ("%s- %s" , monitoringFilesUnitsID , comp .ID ),
443
446
"type" : "filestream" ,
444
447
"paths" : []interface {}{
445
448
comp .InputSpec .Spec .Service .Log .Path ,
@@ -492,8 +495,8 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components []
492
495
493
496
inputs := []interface {}{
494
497
map [string ]interface {}{
495
- idKey : "filestream-monitoring- agent" ,
496
- "name" : "filestream-monitoring- agent" ,
498
+ idKey : fmt . Sprintf ( "%s- agent", monitoringFilesUnitsID ) ,
499
+ "name" : fmt . Sprintf ( "%s- agent", monitoringFilesUnitsID ) ,
497
500
"type" : "filestream" ,
498
501
useOutputKey : monitoringOutput ,
499
502
"streams" : streams ,
@@ -522,14 +525,13 @@ func (b *BeatsMonitor) monitoringNamespace() string {
522
525
}
523
526
524
527
func (b * BeatsMonitor ) injectMetricsInput (cfg map [string ]interface {}, componentIDToBinary map [string ]string , monitoringOutputName string , componentList []component.Component ) error {
525
-
526
528
metricsCollectionIntervalString := metricsCollectionInterval .String ()
527
529
monitoringNamespace := b .monitoringNamespace ()
528
530
fixedAgentName := strings .ReplaceAll (agentName , "-" , "_" )
529
531
beatsStreams := make ([]interface {}, 0 , len (componentIDToBinary ))
530
532
streams := []interface {}{
531
533
map [string ]interface {}{
532
- idKey : "metrics-monitoring- agent" ,
534
+ idKey : fmt . Sprintf ( "%s- agent", monitoringMetricsUnitID ) ,
533
535
"data_stream" : map [string ]interface {}{
534
536
"type" : "metrics" ,
535
537
"dataset" : fmt .Sprintf ("elastic_agent.%s" , fixedAgentName ),
@@ -606,7 +608,18 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
606
608
},
607
609
},
608
610
}
609
- for unit , binaryName := range componentIDToBinary {
611
+
612
+ //create a new map with the monitoring beats included
613
+ componentListWithMonitoring := map [string ]string {
614
+ fmt .Sprintf ("beat/%s" , monitoringMetricsUnitID ): "metricbeat" ,
615
+ fmt .Sprintf ("http/%s" , monitoringMetricsUnitID ): "metricbeat" ,
616
+ monitoringFilesUnitsID : "filebeat" ,
617
+ }
618
+ for k , v := range componentIDToBinary {
619
+ componentListWithMonitoring [k ] = v
620
+ }
621
+
622
+ for unit , binaryName := range componentListWithMonitoring {
610
623
if ! isSupportedMetricsBinary (binaryName ) {
611
624
continue
612
625
}
@@ -616,7 +629,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
616
629
617
630
if isSupportedBeatsBinary (binaryName ) {
618
631
beatsStreams = append (beatsStreams , map [string ]interface {}{
619
- idKey : "metrics-monitoring-" + name ,
632
+ idKey : fmt . Sprintf ( "%s-" , monitoringMetricsUnitID ) + name ,
620
633
"data_stream" : map [string ]interface {}{
621
634
"type" : "metrics" ,
622
635
"dataset" : fmt .Sprintf ("elastic_agent.%s" , name ),
@@ -678,7 +691,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
678
691
}
679
692
680
693
streams = append (streams , map [string ]interface {}{
681
- idKey : "metrics-monitoring-" + name + "-1" ,
694
+ idKey : fmt . Sprintf ( "%s-%s-1" , monitoringMetricsUnitID , name ) ,
682
695
"data_stream" : map [string ]interface {}{
683
696
"type" : "metrics" ,
684
697
"dataset" : fmt .Sprintf ("elastic_agent.%s" , fixedAgentName ),
@@ -748,7 +761,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
748
761
if strings .EqualFold (name , "filebeat" ) {
749
762
fbDataStreamName := "filebeat_input"
750
763
streams = append (streams , map [string ]interface {}{
751
- idKey : "metrics-monitoring-" + name + "-1" ,
764
+ idKey : fmt . Sprintf ( "%s-%s-1" , monitoringMetricsUnitID , name ) ,
752
765
"data_stream" : map [string ]interface {}{
753
766
"type" : "metrics" ,
754
767
"dataset" : fmt .Sprintf ("elastic_agent.%s" , fbDataStreamName ),
@@ -832,7 +845,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
832
845
// note: this doesn't fetch anything from the /state endpoint, as it doesn't report much beyond name/version,
833
846
// the equivalent of the beat /state metrics end up in /shipper
834
847
shipperHTTPStreams = append (shipperHTTPStreams , map [string ]interface {}{
835
- idKey : "metrics-monitoring- shipper" ,
848
+ idKey : fmt . Sprintf ( "%s- shipper", monitoringMetricsUnitID ) ,
836
849
"data_stream" : map [string ]interface {}{
837
850
"type" : "metrics" ,
838
851
"dataset" : fmt .Sprintf ("elastic_agent.%s" , name ),
@@ -846,7 +859,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
846
859
"processors" : createProcessorsForJSONInput (name , comp .ID , monitoringNamespace , b .agentInfo ),
847
860
},
848
861
map [string ]interface {}{
849
- idKey : "metrics-monitoring- shipper-stats" ,
862
+ idKey : fmt . Sprintf ( "%s- shipper-stats", monitoringMetricsUnitID ) ,
850
863
"data_stream" : map [string ]interface {}{
851
864
"type" : "metrics" ,
852
865
"dataset" : fmt .Sprintf ("elastic_agent.%s" , name ),
@@ -864,8 +877,8 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
864
877
865
878
inputs := []interface {}{
866
879
map [string ]interface {}{
867
- idKey : "metrics-monitoring- beats" ,
868
- "name" : "metrics-monitoring- beats" ,
880
+ idKey : fmt . Sprintf ( "%s- beats", monitoringMetricsUnitID ) ,
881
+ "name" : fmt . Sprintf ( "%s- beats", monitoringMetricsUnitID ) ,
869
882
"type" : "beat/metrics" ,
870
883
useOutputKey : monitoringOutput ,
871
884
"data_stream" : map [string ]interface {}{
@@ -874,8 +887,8 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
874
887
"streams" : beatsStreams ,
875
888
},
876
889
map [string ]interface {}{
877
- idKey : "metrics-monitoring- agent" ,
878
- "name" : "metrics-monitoring- agent" ,
890
+ idKey : fmt . Sprintf ( "%s- agent", monitoringMetricsUnitID ) ,
891
+ "name" : fmt . Sprintf ( "%s- agent", monitoringMetricsUnitID ) ,
879
892
"type" : "http/metrics" ,
880
893
useOutputKey : monitoringOutput ,
881
894
"data_stream" : map [string ]interface {}{
@@ -888,8 +901,8 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
888
901
// if we have shipper data, inject the extra inputs
889
902
if len (shipperHTTPStreams ) > 0 {
890
903
inputs = append (inputs , map [string ]interface {}{
891
- idKey : "metrics-monitoring- shipper" ,
892
- "name" : "metrics-monitoring- shipper" ,
904
+ idKey : fmt . Sprintf ( "%s- shipper", monitoringMetricsUnitID ) ,
905
+ "name" : fmt . Sprintf ( "%s- shipper", monitoringMetricsUnitID ) ,
893
906
"type" : "http/metrics" ,
894
907
useOutputKey : monitoringOutput ,
895
908
"data_stream" : map [string ]interface {}{
0 commit comments