简体   繁体   中英

Compare 2 metrics in Prometheus

I'm new in prometheus, need help.

I have custom metric on my 2 servers (just shows version of application):

app_version{plant="dev",env="demo"} 55.119
app_version{plant="dev",env="live"} 55.211

I want to compare this metrics and send ALERT if they are not equal trying for smth like this:

alert: Compare
expr: app_version{env="demo"} != app_version{env="live"}
for: 5s
labels:
  severity: page
annotations:
  summary: Compare

and this alert is green. What the right way to compare 2 metrics?

在此处输入图片说明 在此处输入图片说明

The different value for the env label means that there's nothing to match on each side of the expression, so it returns nothing and there's no alerts. You can adjust this behaviour using ignoring :

app_version{env="demo"} != ignoring (env) app_version{env="live"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM