I want to monitor particular services via node_exporter, without the need to point them in node_exporter service with --collector.systemd.unit-include="(foo|bar)\\.service"
How this should be defined in prometheus config ?
I was trying
- name: Services monitoring
rules:
- alert: Service is down
expr: node_systemd_unit_state{name="ubrokerd|besclient|boksm|collectd|crond|ldapauth|network|NetworkManager|sshd|tomcat|ubrokerd|nginx|node_exporter\\.service", state="inactive"} == 1
for: 0m
labels:
severity: warning
annotations:
summary: service is down on host {{ $labels.instance }}
description: "Service is down"
but this not seems to work - alert is not firing if any of the services go down
There are two problems with your expr
:
=
) instead of regex match (=~
).\\.service
applies only to the last item.Try this:
expr: node_systemd_unit_state{name=~"(ubrokerd|besclient|boksm|collectd|crond|ldapauth|network|NetworkManager|sshd|tomcat|ubrokerd|nginx|node_exporter)\\.service", state="inactive"} == 1