cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/rule/label.md
98lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # rule/label |
| 8 | |
| 9 | This check works the same way as [alerts/annotation](../alerts/annotation.md) check, |
| 10 | but it operates on labels instead. |
| 11 | It uses static labels set on alerting or recording rule. It doesn't use |
| 12 | labels on time series used in those rules. |
| 13 | |
| 14 | ## Configuration |
| 15 | |
| 16 | Syntax: |
| 17 | |
| 18 | ```js |
| 19 | label "$pattern" { |
| 20 | severity = "bug|warning|info" |
| 21 | value = "..." |
| 22 | required = true|false |
| 23 | } |
| 24 | ``` |
| 25 | |
| 26 | - `$pattern` - regexp pattern to match label name on |
| 27 | - `severity` - set custom severity for reported issues, defaults to a warning |
| 28 | - `value` - optional value pattern to enforce, if not set only the |
| 29 | - `required` - if `true` pint will require every rule to have this label set, |
| 30 | if `false` it will only check values where label is set |
| 31 | |
| 32 | ## How to enable it |
| 33 | |
| 34 | This check is not enabled by default as it requires explicit configuration |
| 35 | to work. |
| 36 | To enable it add one or more `rule {...}` blocks and specify all required |
| 37 | labels there. |
| 38 | |
| 39 | Example: |
| 40 | |
| 41 | Require `severity` label to be set on alert rules with two all possible values: |
| 42 | |
| 43 | ```js |
| 44 | rule { |
| 45 | match { |
| 46 | kind = "alerting" |
| 47 | } |
| 48 | |
| 49 | label "severity" { |
| 50 | value = "(warning|critical)" |
| 51 | required = true |
| 52 | } |
| 53 | } |
| 54 | ``` |
| 55 | |
| 56 | ## How to disable it |
| 57 | |
| 58 | You can disable this check globally by adding this config block: |
| 59 | |
| 60 | ```js |
| 61 | checks { |
| 62 | disabled = ["rule/label"] |
| 63 | } |
| 64 | ``` |
| 65 | |
| 66 | Or you can disable it per rule by adding a comment to it: |
| 67 | |
| 68 | `# pint disable rule/label` |
| 69 | |
| 70 | If you want to disable only individual instances of this check |
| 71 | you can add a more specific comment. |
| 72 | |
| 73 | `# pint disable rule/label($label:$required)` |
| 74 | |
| 75 | Where `$label` is the label name and `$required` is the configure value |
| 76 | of `required` option. |
| 77 | |
| 78 | ```yaml |
| 79 | groups: |
| 80 | - name: ... |
| 81 | rules: |
| 82 | # pint disable rule/label($pattern:$required) |
| 83 | - record: ... |
| 84 | expr: ... |
| 85 | ``` |
| 86 | |
| 87 | Example rule: |
| 88 | |
| 89 | ```js |
| 90 | label "severity" { |
| 91 | value = "(warning|critical)" |
| 92 | required = true |
| 93 | } |
| 94 | ``` |
| 95 | |
| 96 | Example comment disabling that rule: |
| 97 | |
| 98 | `# pint disable rule/label(severity:true)` |
| 99 | |