@@ -1174,20 +1174,22 @@ func prepareMetrics(targetContext *targetContext, localTempDir string, channelEr
11741174 channelError <- targetError {target : myTarget , err : err }
11751175 return
11761176 }
1177- for _ , def := range targetContext .metricDefinitions {
1178- desc := fmt .Sprintf ("%s (expr: %s)" , def .Name , def .Expression )
1179- name := promMetricPrefix + sanitizeMetricName (def .Name )
1180- gauge := prometheus .NewGaugeVec (
1181- prometheus.GaugeOpts {
1182- Name : name ,
1183- Help : desc ,
1184- },
1185- []string {"socket" , "cpu" , "cgroup" , "pid" , "cmd" },
1186- )
1187- promMetrics [name ] = gauge
1188- }
1189- for _ , m := range promMetrics {
1190- prometheus .MustRegister (m )
1177+ if flagPrometheusServer {
1178+ for _ , def := range targetContext .metricDefinitions {
1179+ desc := fmt .Sprintf ("%s (expr: %s)" , def .Name , def .Expression )
1180+ name := promMetricPrefix + sanitizeMetricName (def .Name )
1181+ gauge := prometheus .NewGaugeVec (
1182+ prometheus.GaugeOpts {
1183+ Name : name ,
1184+ Help : desc ,
1185+ },
1186+ []string {"socket" , "cpu" , "cgroup" , "pid" , "cmd" },
1187+ )
1188+ promMetrics [name ] = gauge
1189+ }
1190+ for _ , m := range promMetrics {
1191+ prometheus .MustRegister (m )
1192+ }
11911193 }
11921194 channelError <- targetError {target : myTarget , err : nil }
11931195}
0 commit comments