PromQL - Absenth - labels

127 views
Skip to first unread message

fiala...@gmail.com

unread,
Apr 15, 2021, 7:50:16 AM4/15/21
to Prometheus Users
Hi,

I have cpu usage exporter with these metrics for every running processes.
process_cpu_usage{command="/usr/bin/rsyslog -n"} 0.12

I would like to use this exporter for monitoring if process is running.

I've tried to use absent -  but with regexp match it doesn't return "command" label. And I need it for alert description
Eg: 
absent(process_cpu_usage{command=~"/usr/sbin/rsyslogd.*", instance="my-server.com"})

Is there a way how to add label to vector(0)?

Or do you know any other way, how to solve it?

Thank you.


Matt Doughty

unread,
Apr 15, 2021, 10:06:28 AM4/15/21
to fiala...@gmail.com, Prometheus Users
Absent doesn't return labels because there aren't any. Add the labels you need for the alert identification in the labels section.

--Matt

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/42c7e7dc-e32b-42f8-b7e9-a19d2ec0f485n%40googlegroups.com.

fiala...@gmail.com

unread,
Apr 15, 2021, 10:52:39 AM4/15/21
to Prometheus Users
I wanted to make this alert with lots of processes.

Eg.: absent(process_cpu_usage{command=~"/usr/sbin/rsyslogd.*") or absent(process_cpu_usage{command=~"/usr/sbin/mysql") or absent(....)

Matt Doughty

unread,
Apr 15, 2021, 11:22:34 AM4/15/21
to fiala...@gmail.com, Prometheus Users
Absent doesn't work that way. It just tells you that there are no timeseries that match. As a result, when it fires there are no labels to give back to you.

If you make a broad regex, the alert won't fire unless there are no matches at all. For that reason, you will need a discrete alert for every process you want to monitor.

--Matt





--
--Matt
Reply all
Reply to author
Forward
0 new messages