prometheus/prometheus

promtool: Allow inexact matches in exp_alerts

Open

#7,370 opened on Jun 9, 2020

View on GitHub
 (8 comments) (16 reactions) (1 assignee)Go (10,408 forks)batch import
component/promtoolhelp wantedkind/enhancementpriority/Pmaybe

Repository metrics

Stars
 (64,042 stars)
PR merge metrics
 (Avg merge 11d 5h) (118 merged PRs in 30d)

Description

Proposal

Use case. Why is this important? Currently, when building a rule test, one needs the exp_alerts to be exact matches of the alert that would fire, with all labels and annotations. Since these can be fairly rich in real-world usage, I propose that matching can be "inexact". Rather than all labels and annotations being exact matches, only those actually present in the exp_labels and exp_annotations must match. I frequently come across organisations where entire runbooks are written in annotations, and duplicating those into each rule adds a lot of friction to test adoption. Fixing a typo in the runbook breaking unit tests, for example.

This could be made opt-in with a matching_mode or such, if there is a frequent desire to match all the things.

Alternatively, or perhap as a complement, being able to check for presence but ignoring content. This could facilitate something like a test that validates that all alerting rules have a runbook, for example.

Contributor guide