cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.41.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/checks/alerts/annotation.md

156lines · modecode

1---
2layout: default
3parent: Checks
4grand_parent: Documentation
5---
6
7# alerts/annotation
8
9This check can be used to enforce annotations on alerting rules.
10
11## Configuration
12
13Syntax:
14
15```js
16annotation "$pattern" {
17 severity = "bug|warning|info"
18 value = "(.*)"
19 required = true|false
20}
21```
22
23- `$pattern` - regexp pattern to match annotation name on, this can be templated
24 to reference checked rule fields, see [Configuration](../../configuration.md)
25 for details
26- `severity` - set custom severity for reported issues, defaults to a warning
27- `value` - optional value pattern to enforce, if not set only the
28- `required` - if `true` pint will require every alert to have this annotation set,
29 if `false` it will only check values where annotation is set
30
31## How to enable it
32
33This check is not enabled by default as it requires explicit configuration
34to work.
35To enable it add one or more `rule {...}` blocks and specify all required
36annotations there.
37
38Example set of rules that will:
39- require `summary` annotation to be present, if missing it will be reported as a warning
40- if a `dashboard` annotation is provided it must match `https://grafana\.example\.com/.+`
41 pattern, if it doesn't match that pattern it will be reported as a bug
42
43```js
44rule {
45 match {
46 kind = "alerting"
47 }
48
49 annotation "summary" {
50 required = true
51 }
52
53 annotation "dashboard" {
54 severity = "bug"
55 value = "https://grafana\.example\.com/.+"
56 }
57}
58```
59
60Example that enforces all alerting rules with non-zero `for` field to have an
61annotation called `alert_for` and value equal to `for` field.
62
63{% raw %}
64```js
65rule {
66 match {
67 for = "> 0"
68 }
69
70 annotation "alert_for" {
71 required = true
72 value = "{{ $for }}"
73 }
74}
75```
76{% endraw %}
77
78## How to disable it
79
80You can disable this check globally by adding this config block:
81
82```js
83checks {
84 disabled = ["alerts/annotations"]
85}
86```
87
88You can also disable it for all rules inside given file by adding
89a comment anywhere in that file. Example:
90
91`# pint file/disable alerts/annotation`
92
93Or you can disable it per rule by adding a comment to it. Example:
94
95`# pint disable alerts/annotation`
96
97If you want to disable only individual instances of this check
98you can add a more specific comment.
99
100### If `value` is NOT set
101
102```yaml
103groups:
104 - name: ...
105 rules:
106 # pint disable alerts/annotation($pattern:$required)
107 - record: ...
108 expr: ...
109```
110
111Example rule:
112
113```js
114annotation "summary" {
115 required = true
116}
117```
118
119Example comment disabling that rule:
120
121`# pint disable alerts/annotation(summary:true)`
122
123### If `value` is set
124
125```yaml
126groups:
127 - name: ...
128 rules:
129 # pint disable alerts/annotation($pattern:$value:$required)
130 - record: ...
131 expr: ...
132```
133
134Example rule:
135
136```js
137annotation "dashboard" {
138 severity = "bug"
139 value = "https://grafana\.example\.com/.+"
140}
141```
142
143Example comment disabling that rule:
144
145`# pint disable alerts/annotation(dashboard:https://grafana\.example\.com/.+:true)`
146
147## How to snooze it
148
149You can disable this check until given time by adding a comment to it. Example:
150
151`# pint snooze $TIMESTAMP alerts/annotation`
152
153Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339)
154formatted or `YYYY-MM-DD`.
155Adding this comment will disable `alerts/annotation` *until* `$TIMESTAMP`, after that
156check will be re-enabled.
157