我希望通过node_exporter监视特定的服务,而不需要用--collector.systemd.unit-include="(foo|bar)\\.service"在node_exporter服务中指向它们。
如何在prometheus配置中定义这一点?
我在试着
- 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"但这似乎不起作用--如果任何服务出现故障,警报就不会启动。
发布于 2022-03-25 10:15:56
您的expr有两个问题
使用文字匹配运算符( (=~).
\\.service只适用于最后一项。试试这个:
expr: node_systemd_unit_state{name=~"(ubrokerd|besclient|boksm|collectd|crond|ldapauth|network|NetworkManager|sshd|tomcat|ubrokerd|nginx|node_exporter)\\.service", state="inactive"} == 1https://stackoverflow.com/questions/71614631
复制相似问题