cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.48.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/rule/label.md

146lines · 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
63```js
64rule {
65 match {
66 for = "> 5m"
67 }
68
69 label "alert_for" {
70 required = true
71 value = "{{ $for }}"
72 }
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 = ["rule/label"]
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```yaml
92# pint file/disable rule/label
93```
94
95Or you can disable it per rule by adding a comment to it. Example:
96
97```yaml
98# pint disable rule/label
99```
100
101If you want to disable only individual instances of this check
102you can add a more specific comment.
103
104```yaml
105# pint disable rule/label($label:$required)
106```
107
108Where `$label` is the label name and `$required` is the configure value
109of `required` option.
110
111```yaml
112groups:
113 - name: ...
114 rules:
115 # pint disable rule/label($pattern:$required)
116 - record: ...
117 expr: ...
118```
119
120Example rule:
121
122```js
123label "severity" {
124 value = "(warning|critical)"
125 required = true
126}
127```
128
129Example comment disabling that rule:
130
131```yaml
132# pint disable rule/label(severity:true)
133```
134
135## How to snooze it
136
137You can disable this check until given time by adding a comment to it. Example:
138
139```yaml
140# pint snooze $TIMESTAMP rule/label
141```
142
143Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339)
144formatted or `YYYY-MM-DD`.
145Adding this comment will disable `rule/label` *until* `$TIMESTAMP`, after that
146check will be re-enabled.
147