0

I'm starting to write unit tests for Prometheus PromQL alerts using promtool test rules. Basic tests work, but I'd also like to write tests that check whether an alarm didn't fire for a certain series of values.

Is this possible and how would I express such a test?

1 Answers1

2

I think I have figured it out.

Just provide an empty exp_alerts in the test:

evaluation_interval: 1m
tests:
  - interval: 10s
    input_series:
    - series: '...'
      values: '...'
    alert_rule_test: 
      - eval_time: 10m
        alertname: my_alert
        exp_alerts:

This will pass if there are no alerts, and will fail if alerts fired.