Search code examples
prometheusprometheus-alertmanager

How to write an alert for data exposed by blackbox exporter?


I have probe_success{job="my_service"} that is generated every 1 hour by blackbox exporter and it's either 0 or 1.

What's the correct expression to generate an alert?

Is probe_success{job="my_service"} == 0 correct?

enter image description here


Solution

  • Expression-wise probe_success == 0 or probe_success != 1 are valid choices.

    However, you made it so that the metric appears only once in an hour which makes it impossible to use with the for alert parameter. In other words, your alert will only work without for and with that you will have all sorts of false alarms because of network glitches and other short random events.

    If you want to use for, then you should set the scrape interval for the job to at least 5 minutes.