cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.17.5

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/rule/label.md

118lines · 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
86Or you can disable it per rule by adding a comment to it:
87
88`# pint disable rule/label`
89
90If you want to disable only individual instances of this check
91you can add a more specific comment.
92
93`# pint disable rule/label($label:$required)`
94
95Where `$label` is the label name and `$required` is the configure value
96of `required` option.
97
98```yaml
99groups:
100 - name: ...
101 rules:
102 # pint disable rule/label($pattern:$required)
103 - record: ...
104 expr: ...
105```
106
107Example rule:
108
109```js
110label "severity" {
111 value = "(warning|critical)"
112 required = true
113}
114```
115
116Example comment disabling that rule:
117
118`# pint disable rule/label(severity:true)`
119