filter node_systemd_unit_state metric

64 views
Skip to first unread message

hyl dop

unread,
Nov 12, 2023, 10:13:48 AM11/12/23
to Prometheus Users
Hi, I'd like to filter the node_systemd_unit_state metric to display only a few services on Grafana.

So I thought of creating a new metric in a *.prom file using the --collector.textfile.directory option. The problem is that I don't know if it's possible to create a metric using an existing metric.

For example, I'd like the metric I create to display the result of these metrics :

node_systemd_unit_state{name=~"Net.service"} == 1
node_systemd_unit_state{name=~"fedo.*"} == 1 node_systemd_unit_state{name=~"grara.*"} == 1

Thank you in advance for your reply


Brian Candler

unread,
Nov 12, 2023, 6:48:01 PM11/12/23
to Prometheus Users
Why do you not just filter it in the query at the Grafana end?  That is, why do you need to create a new metric?

Also: if you *do* need to create a new metric which is just a subset of an existing metric, then prometheus recording rules would be better than dropping files for the textfile collector.
Reply all
Reply to author
Forward
0 new messages