ezgh obs alert-rules import <rules.yaml> [--contact-point cp]... [--update] [--dry-run] [flags]Turn each alerting rule of a Prometheus rule file (groups of rules with alert, expr, for, keep_firing_for, labels and annotations) into an alert rule, with Prometheus’s semantics: the expression includes the comparison, and every series it returns is an instance. A group’s labels go under each rule’s. for and keep_firing_for round up to whole minutes, since EZGH evaluates every minute (and a group interval other than 1m is reported). An alert name the file repeats (often one rule per severity) becomes “<alert> (<severity>)”, or “<alert> #2”.
What can’t be imported is listed, and nothing is sent for it: recording rules, the @ modifier, a range, subquery or offset over 1 hour, labels that are templates (EZGH’s labels are plain text), and annotation templates that call query (EZGH’s templates can’t run queries) or $externalURL. obs-api checks each rule again, and one it refuses is reported with its problems while the others go on.
--contact-point (ID, slug or name; repeatable) is set on every imported rule. A rule whose name is already in the project is left alone unless --update, which replaces its condition, for, keep_firing_for, labels and annotations (and contact points, when given) and keeps the rest. --dry-run lists what would happen and sends nothing. It exits 1 if any rule failed.
Part of ezgh obs alert-rules.
Examples
ezgh obs alert-rules import prometheus/alerts.yaml --contact-point "Platform on-call" --dry-run
ezgh obs alert-rules import prometheus/alerts.yaml --contact-point "Platform on-call"
ezgh obs alert-rules import prometheus/alerts.yaml --updateFlags
| Flag | Type | Default | Description |
|---|---|---|---|
--contact-point |
string, repeatable | a contact point (ID, slug or name) for every imported rule (repeatable) | |
--dry-run |
boolean | list what would happen, and send nothing | |
--update |
boolean | replace rules whose name is already in the project |
This command also takes the global flags.