cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/rule/for.md
117lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # rule/for |
| 8 | |
| 9 | This check allows to enforce the presence of `for` or `keep_firing_for` field |
| 10 | on alerting rules. |
| 11 | You can configure it to enforce some minimal and/or maximum duration |
| 12 | set on alerts via `for` and/or `keep_firing_for` fields. |
| 13 | |
| 14 | ## Configuration |
| 15 | |
| 16 | This check doesn't have any configuration options. |
| 17 | |
| 18 | ## How to enable it |
| 19 | |
| 20 | This check uses either `for` or `keep_firing_for` configuration |
| 21 | blocks, depending on which alerting rule field you want to enforce. |
| 22 | |
| 23 | Syntax: |
| 24 | |
| 25 | ```js |
| 26 | for { |
| 27 | comment = "comment" |
| 28 | severity = "bug|warning|info" |
| 29 | min = "5m" |
| 30 | max = "10m" |
| 31 | } |
| 32 | keep_firing_for { |
| 33 | comment = "comment" |
| 34 | severity = "bug|warning|info" |
| 35 | min = "5m" |
| 36 | max = "10m" |
| 37 | } |
| 38 | ``` |
| 39 | |
| 40 | - `comment` - set a custom comment that will be added to reported problems. |
| 41 | - `severity` - set custom severity for reported issues, defaults to a bug. |
| 42 | - `min` - minimum required `for` value for matching alerting rules. |
| 43 | If not set minimum `for` duration won't be enforced. |
| 44 | - `max` - maximum allowed `for` value for matching alerting rules. |
| 45 | - If not set maximum `for` duration won't be enforced. |
| 46 | |
| 47 | Example: |
| 48 | |
| 49 | Enforce that all alerts have `for` fields of `5m` or more: |
| 50 | |
| 51 | ```js |
| 52 | for { |
| 53 | comment = "All alert rules must have for:5m (or more) to avoid flaky alerts" |
| 54 | severity = "bug" |
| 55 | min = "5m" |
| 56 | } |
| 57 | ``` |
| 58 | |
| 59 | Enforce that all alerts have `keep_firing_for` fields with no more than `1h`: |
| 60 | |
| 61 | ```js |
| 62 | keep_firing_for { |
| 63 | severity = "bug" |
| 64 | max = "1h" |
| 65 | } |
| 66 | ``` |
| 67 | |
| 68 | To enforce both at the same time: |
| 69 | |
| 70 | ```js |
| 71 | for { |
| 72 | severity = "bug" |
| 73 | min = "5m" |
| 74 | max = "10m" |
| 75 | } |
| 76 | |
| 77 | keep_firing_for { |
| 78 | severity = "bug" |
| 79 | max = "1h" |
| 80 | } |
| 81 | ``` |
| 82 | |
| 83 | ## How to disable it |
| 84 | |
| 85 | You can disable this check globally by adding this config block: |
| 86 | |
| 87 | ```js |
| 88 | checks { |
| 89 | disabled = ["rule/for"] |
| 90 | } |
| 91 | ``` |
| 92 | |
| 93 | You can also disable it for all rules inside given file by adding |
| 94 | a comment anywhere in that file. Example: |
| 95 | |
| 96 | ```yaml |
| 97 | # pint file/disable rule/for |
| 98 | ``` |
| 99 | |
| 100 | Or you can disable it per rule by adding a comment to it. Example: |
| 101 | |
| 102 | ```yaml |
| 103 | # pint disable rule/for |
| 104 | ``` |
| 105 | |
| 106 | ## How to snooze it |
| 107 | |
| 108 | You can disable this check until given time by adding a comment to it. Example: |
| 109 | |
| 110 | ```yaml |
| 111 | # pint snooze $TIMESTAMP rule/for |
| 112 | ``` |
| 113 | |
| 114 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 115 | formatted or `YYYY-MM-DD`. |
| 116 | Adding this comment will disable `rule/duplicate` *until* `$TIMESTAMP`, after that |
| 117 | check will be re-enabled. |
| 118 | |