send alert with severity variable

29 views
Skip to first unread message

Gabor Kiss

unread,
Jul 28, 2021, 6:16:54 AM7/28/21
to Prometheus Users
Hi there!

I have a situation, and I'm trying to solve this. I have an alerting rule:

expr: up{job="blackbox_probe"} == 0 or probe_success{job="blackbox_probe"} == 0
      for: 1m
      labels:
        severity: warning 
      annotations:
        summary: "Site down! (instance {{ $labels.instance }})"

The targets a have their owners and a severity variable. I did this:

expr: up{job="blackbox_probe"} == 0 or probe_success{job="blackbox_probe"} == 0
      for: 1m
      labels:
        severity: {{ $labels.severity }} 
      annotations:
        summary: "Site down! (instance {{ $labels.instance }})"

if it's critical , it's goes to the pagerduty, if it's warning , sends an email. That's my goal.  Any hint what went wrong? 
Thanks!

Ben Kochie

unread,
Jul 28, 2021, 6:34:23 AM7/28/21
to Gabor Kiss, Prometheus Users
If you have labels already on the metrics, you don't need to do anything. All labels from the expr are passed to the alertmanager.

From there, you can route however you want.

--
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/b3a58b32-3bcb-48b1-8399-ca67f2881165n%40googlegroups.com.

Gabor Kiss

unread,
Jul 28, 2021, 7:41:57 AM7/28/21
to Prometheus Users

Exactly! That's what I missed :D Thanks for that! 
Reply all
Reply to author
Forward
0 new messages