process exporter alerts

227 views
Skip to first unread message

Miha Zoubek

unread,
Oct 4, 2022, 12:03:05 PM10/4/22
to Prometheus Users
Hello

I am using process exporter to get how much certain process is consuming memory.

namedprocess_namegroup_memory_bytes{groupname="map[:process.jar]", memtype!="residential"}

How can I make an alert so that I am notified when residential memory reaches a certain amount of virtual memory of a process?

 The thing is that I can not do this.

namedprocess_namegroup_memory_bytes{groupname="map[:process.jar]", memtype!="residential"} - namedprocess_namegroup_memory_bytes{groupname="map[:process.jar]", memtype!="virtual"}

Brian Candler

unread,
Oct 4, 2022, 4:59:00 PM10/4/22
to Prometheus Users
> The thing is that I can not do this.

If you subtract two instance vectors, then only the elements with *exactly* matching labels will be retained, as documented here.  In your case the LHS and RHS have different labels, so you will get an empty result.

But you make the LHS and RHS match on specific labels, or ignoring specific labels, as documented here.

In your example, you can try this, assuming all the other labels match:

namedprocess_namegroup_memory_bytes{groupname="map[:process.jar]", memtype="virtual"} - ignoring(memtype) namedprocess_namegroup_memory_bytes{groupname="map[:process.jar]", memtype="residential"}

Note that I changed the label matching from not-equal to equal, to be sure there's only one value on the LHS which matches the value on the RHS, assuming all other labels are the same.

If you need to combine multiple values for different memtypes on either the LHS or the RHS then you will need to sum(...) over them.

I wrote a longer explanation of a similar issue recently:

Reply all
Reply to author
Forward
0 new messages