cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.15.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/alerts/annotation.md

140lines · 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
88Or you can disable it per rule by adding a comment to it.
89
90`# pint disable alerts/annotation`
91
92If you want to disable only individual instances of this check
93you can add a more specific comment.
94
95### If `value` is NOT set
96
97```yaml
98groups:
99 - name: ...
100 rules:
101 # pint disable alerts/annotation($pattern:$required)
102 - record: ...
103 expr: ...
104```
105
106Example rule:
107
108```js
109annotation "summary" {
110 required = true
111}
112```
113
114Example comment disabling that rule:
115
116`# pint disable alerts/annotation(summary:true)`
117
118### If `value` is set
119
120```yaml
121groups:
122 - name: ...
123 rules:
124 # pint disable alerts/annotation($pattern:$value:$required)
125 - record: ...
126 expr: ...
127```
128
129Example rule:
130
131```js
132annotation "dashboard" {
133 severity = "bug"
134 value = "https://grafana\.example\.com/.+"
135}
136```
137
138Example comment disabling that rule:
139
140`# pint disable alerts/annotation(dashboard:https://grafana\.example\.com/.+:true)`
141