cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.42.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/rule/label.md

134lines · modecode

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