add custom label to node_systemd_unit_state metric

224 views
Skip to first unread message

Richie

unread,
Aug 18, 2023, 8:05:48 AM8/18/23
to Prometheus Users
I am trying to add a label to the mentioned metric from the grafana agent config.  I have tried the static label config, the relabel configs and metric_relabel_configs blocks but no luck.

example:
          relabel_configs:
         - source_labels: [__address__]
           target_label: group
           replacement: "group1"

The new label shows up on many of the metrics but for whatever reason it doesn't show up in node_systemd_unit_state metric.

The reasoning for this is for alerting so that I can filter groups of nodes have their alerts  to go specific contacts.

Screenshot_20230817_165243.pngScreenshot_20230817_165524.png

Brian Candler

unread,
Aug 18, 2023, 8:18:33 AM8/18/23
to Prometheus Users
relabel_configs are per scrape job.  It appears that you've applied this config to the job called "agent" but not to the job called "integrations/node_exporter"

Richie

unread,
Aug 18, 2023, 9:20:57 AM8/18/23
to Prometheus Users
Brian, thanks for the hint,  pasting working excerpt below

integrations:
 node_exporter:
   enabled: true
   enable_collectors:
     - systemd
   relabel_configs:
     - source_labels: [__address__]
       target_label: group
       replacement: "group1"

Brian Candler

unread,
Aug 18, 2023, 11:50:39 AM8/18/23
to Prometheus Users
Aside: I believe there is no need for source_labels here, since you're not matching on them.

     - target_label: group
       replacement: group1

should be sufficient. ("action: replace" is default)

Richie

unread,
Aug 24, 2023, 11:00:10 AM8/24/23
to Prometheus Users
yes that worked, thanks
Reply all
Reply to author
Forward
0 new messages