layout | parent | grand_parent |
---|---|---|
default |
Checks |
Documentation |
This check can be used to enforce annotations on alerting rules.
Syntax:
annotation "$pattern" {
severity = "bug|warning|info"
value = "(.*)"
required = true|false
}
$pattern
- regexp pattern to match annotation name on, this can be templated to reference checked rule fields, see Configuration for details.severity
- set custom severity for reported issues, defaults to a warning.value
- optional value pattern to enforce, if not set only the.required
- iftrue
pint will require every alert to have this annotation set, iffalse
it will only check values where annotation is set.
This check is not enabled by default as it requires explicit configuration
to work.
To enable it add one or more rule {...}
blocks and specify all required
annotations there.
Example set of rules that will:
- require
summary
annotation to be present, if missing it will be reported as a warning - if a
dashboard
annotation is provided it must matchhttps://grafana\.example\.com/.+
pattern, if it doesn't match that pattern it will be reported as a bug
rule {
match {
kind = "alerting"
}
annotation "summary" {
required = true
}
annotation "dashboard" {
severity = "bug"
value = "https://grafana\.example\.com/.+"
}
}
Example that enforces all alerting rules with non-zero for
field to have an
annotation called alert_for
and value equal to for
field.
{% raw %}
rule {
match {
for = "> 0"
}
annotation "alert_for" {
required = true
value = "{{ $for }}"
}
}
{% endraw %}
You can disable this check globally by adding this config block:
checks {
disabled = ["alerts/annotations"]
}
You can also disable it for all rules inside given file by adding a comment anywhere in that file. Example:
# pint file/disable alerts/annotation
Or you can disable it per rule by adding a comment to it. Example:
# pint disable alerts/annotation
If you want to disable only individual instances of this check you can add a more specific comment.
groups:
- name: ...
rules:
# pint disable alerts/annotation($pattern:$required)
- record: ...
expr: ...
Example rule:
annotation "summary" {
required = true
}
Example comment disabling that rule:
# pint disable alerts/annotation(summary:true)
groups:
- name: ...
rules:
# pint disable alerts/annotation($pattern:$value:$required)
- record: ...
expr: ...
Example rule:
annotation "dashboard" {
severity = "bug"
value = "https://grafana\.example\.com/.+"
}
Example comment disabling that rule:
# pint disable alerts/annotation(dashboard:https://grafana\.example\.com/.+:true)
You can disable this check until given time by adding a comment to it. Example:
# pint snooze $TIMESTAMP alerts/annotation
Where $TIMESTAMP
is either use RFC3339
formatted or YYYY-MM-DD
.
Adding this comment will disable alerts/annotation
until $TIMESTAMP
, after that
check will be re-enabled.