@@ -910,84 +910,89 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
910
910
},
911
911
}
912
912
913
+ for _ , comp := range componentList {
914
+ logp .L ().Infof ("input component %s: %#v" , comp .ID , comp .InputSpec .Spec .Service )
915
+ }
916
+
913
917
// add system/process metrics for services that can't be monitored via json/beats metrics
914
- // If there's a checkin PID and it contains the "endpoint" string, assume we want to monitor it
915
- for id , comp := range existingStateServicePids {
916
- logp . L (). Infof ( "component/pid monitoring map is: %#v" , existingStateServicePids )
917
- if comp != 0 && strings . Contains ( id , "endpoint" ) {
918
- logp . L (). Infof ( "creating system/process watcher for pid %d" , comp )
919
- inputs = append ( inputs , map [ string ] interface {}{
920
- idKey : fmt .Sprintf ("%s-endpoint_security" , monitoringMetricsUnitID ),
921
- "name " : fmt . Sprintf ( "%s-endpoint_security" , monitoringMetricsUnitID ) ,
922
- "type" : "system/metrics" ,
923
- useOutputKey : monitoringOutput ,
924
- "data_stream " : map [ string ] interface {}{
925
- "namespace" : monitoringNamespace ,
926
- },
927
- "streams" : [ ]interface {}{
928
- map [ string ] interface {}{
929
- idKey : fmt . Sprintf ( "%s-endpoint_security" , monitoringMetricsUnitID ),
930
- "data_stream " : map [ string ] interface {}{
931
- "type " : "metrics " ,
932
- "dataset " : "elastic_agent.endpoint_security" ,
933
- "namespace" : monitoringNamespace ,
934
- },
935
- "metricsets " : [] interface {}{ "process" } ,
936
- "period " : metricsCollectionIntervalString ,
937
- "index " : fmt . Sprintf ( "metrics-elastic_agent.endpoint_security-%s" , monitoringNamespace ) ,
938
- "process.pid " : comp ,
939
- "process.cgroups.enabled " : false ,
940
- "processors" : [ ]interface {}{
941
- map [string ]interface {}{
942
- "add_fields " : map [ string ] interface {}{
943
- "target " : "data_stream" ,
944
- "fields " : map [ string ] interface {}{
945
- "type " : "metrics " ,
946
- "dataset " : "elastic_agent.endpoint_security" ,
947
- "namespace" : monitoringNamespace ,
918
+ // If there's a checkin PID and the corrisponding component has a service spec section, add a system/process config
919
+ for _ , compState := range componentList {
920
+ if compState . InputSpec != nil && compState . InputSpec . Spec . Service != nil {
921
+ if comp , ok := existingStateServicePids [ compState . ID ]; ok && comp != 0 {
922
+ inputs = append ( inputs , map [ string ] interface {}{
923
+ idKey : fmt . Sprintf ( "%s-endpoint_security" , monitoringMetricsUnitID ),
924
+ "name" : fmt .Sprintf ("%s-endpoint_security" , monitoringMetricsUnitID ),
925
+ "type " : "system/metrics" ,
926
+ useOutputKey : monitoringOutput ,
927
+ "data_stream" : map [ string ] interface {}{
928
+ "namespace " : monitoringNamespace ,
929
+ } ,
930
+ "streams" : [] interface {}{
931
+ map [ string ]interface {}{
932
+ idKey : fmt . Sprintf ( "%s-endpoint_security" , monitoringMetricsUnitID ),
933
+ "data_stream" : map [ string ] interface {}{
934
+ "type " : "metrics" ,
935
+ "dataset " : "elastic_agent.endpoint_security " ,
936
+ "namespace " : monitoringNamespace ,
937
+ } ,
938
+ "metricsets" : [] interface {}{ "process" },
939
+ "period " : metricsCollectionIntervalString ,
940
+ "index " : fmt . Sprintf ( "metrics-elastic_agent.endpoint_security-%s" , monitoringNamespace ) ,
941
+ "process.pid " : comp ,
942
+ "process.cgroups.enabled " : false ,
943
+ "processors " : [] interface {}{
944
+ map [ string ]interface {}{
945
+ "add_fields" : map [string ]interface {}{
946
+ "target " : "data_stream" ,
947
+ "fields " : map [ string ] interface {}{
948
+ "type " : "metrics" ,
949
+ "dataset " : "elastic_agent.endpoint_security " ,
950
+ "namespace " : monitoringNamespace ,
951
+ } ,
948
952
},
949
953
},
950
- },
951
- map [string ]interface {}{
952
- "add_fields " : map [ string ] interface {}{
953
- "target " : "event" ,
954
- "fields " : map [ string ] interface {}{
955
- "dataset" : "elastic_agent.endpoint_security" ,
954
+ map [ string ] interface {}{
955
+ "add_fields" : map [string ]interface {}{
956
+ "target " : "event" ,
957
+ "fields " : map [ string ] interface {}{
958
+ "dataset " : "elastic_agent.endpoint_security" ,
959
+ } ,
956
960
},
957
961
},
958
- },
959
- map [string ]interface {}{
960
- "add_fields " : map [ string ] interface {}{
961
- "target " : "elastic_agent" ,
962
- "fields " : map [ string ] interface {}{
963
- "id " : b .agentInfo .AgentID (),
964
- "version " : b .agentInfo .Version (),
965
- "snapshot " : b . agentInfo . Snapshot () ,
966
- "process" : "endpoint_security" ,
962
+ map [ string ] interface {}{
963
+ "add_fields" : map [string ]interface {}{
964
+ "target " : "elastic_agent" ,
965
+ "fields " : map [ string ] interface {}{
966
+ "id " : b . agentInfo . AgentID (),
967
+ "version " : b .agentInfo .Version (),
968
+ "snapshot " : b .agentInfo .Snapshot (),
969
+ "process " : "endpoint_security" ,
970
+ } ,
967
971
},
968
972
},
969
- },
970
- map [string ]interface {}{
971
- "add_fields " : map [ string ] interface {}{
972
- "target " : "agent" ,
973
- "fields " : map [ string ] interface {}{
974
- "id" : b . agentInfo . AgentID () ,
973
+ map [ string ] interface {}{
974
+ "add_fields" : map [string ]interface {}{
975
+ "target " : "agent" ,
976
+ "fields " : map [ string ] interface {}{
977
+ "id " : b . agentInfo . AgentID (),
978
+ } ,
975
979
},
976
980
},
977
- },
978
- map [string ]interface {}{
979
- "add_fields " : map [ string ] interface {}{
980
- "target " : "component" ,
981
- "fields " : map [ string ] interface {}{
982
- "binary " : "endpoint_security" ,
983
- "id" : id ,
981
+ map [ string ] interface {}{
982
+ "add_fields" : map [string ]interface {}{
983
+ "target " : "component" ,
984
+ "fields " : map [ string ] interface {}{
985
+ "binary " : "endpoint_security" ,
986
+ "id " : compState . ID ,
987
+ } ,
984
988
},
985
989
},
986
990
},
987
991
},
988
992
},
989
- },
990
- })
993
+ })
994
+ }
995
+
991
996
}
992
997
}
993
998
0 commit comments