cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/alerts/count.md
136lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # alerts/count |
| 8 | |
| 9 | This check is used to estimate how many times given alert would fire. |
| 10 | It will run `expr` query from every alert rule against selected Prometheus |
| 11 | servers and report how many unique alerts it would generate. |
| 12 | If `for` and/or `keep_firing_for` are set on alerts they will be used to adjust results. |
| 13 | |
| 14 | ## Configuration |
| 15 | |
| 16 | Syntax: |
| 17 | |
| 18 | ```js |
| 19 | alerts { |
| 20 | range = "1h" |
| 21 | step = "1m" |
| 22 | resolve = "5m" |
| 23 | minCount = 0 |
| 24 | comment = "..." |
| 25 | severity = "bug|warning|info" |
| 26 | } |
| 27 | ``` |
| 28 | |
| 29 | - `range` - query range, how far to look back, `1h` would mean that pint will |
| 30 | query last 1h of metrics. |
| 31 | Defaults to `1d`. |
| 32 | - `step` - query resolution, for most accurate result use step equal |
| 33 | to `scrape_interval`, try to reduce it if that would load too many samples. |
| 34 | Defaults to `1m`. |
| 35 | - `resolve` - duration after which stale alerts are resolved. Defaults to `5m`. |
| 36 | - `minCount` - minimal number of alerts for this check to report it. Default to `0`. |
| 37 | Set this to a no-zero value if you want this check to report only if the estimated |
| 38 | number of alerts is high enough. |
| 39 | - `comment` - set a custom comment that will be added to reported problems. |
| 40 | - `severity` - set custom severity for reported issues, defaults to `info`. |
| 41 | This can be only set when `minCount` is set to a non-zero value. |
| 42 | |
| 43 | ## How to enable it |
| 44 | |
| 45 | This check is not enabled by default as it requires explicit configuration |
| 46 | to work. |
| 47 | To enable it add one or more `prometheus {...}` blocks and a `rule {...}` block |
| 48 | with this checks config. |
| 49 | |
| 50 | Example: |
| 51 | |
| 52 | ```js |
| 53 | prometheus "prod" { |
| 54 | uri = "https://prometheus-prod.example.com" |
| 55 | timeout = "60s" |
| 56 | } |
| 57 | |
| 58 | rule { |
| 59 | alerts { |
| 60 | range = "1d" |
| 61 | step = "1m" |
| 62 | resolve = "5m" |
| 63 | } |
| 64 | } |
| 65 | ``` |
| 66 | |
| 67 | Report an error if there would be too many (>=50) alerts firing: |
| 68 | |
| 69 | ```js |
| 70 | prometheus "prod" { |
| 71 | uri = "https://prometheus-prod.example.com" |
| 72 | timeout = "60s" |
| 73 | } |
| 74 | |
| 75 | rule { |
| 76 | alerts { |
| 77 | range = "1d" |
| 78 | step = "1m" |
| 79 | resolve = "5m" |
| 80 | minCount = 50 |
| 81 | comment = "You cannot add an rule that would immediately fire 50+ alerts, fix the problem first" |
| 82 | severity = "bug" |
| 83 | } |
| 84 | } |
| 85 | ``` |
| 86 | |
| 87 | ## How to disable it |
| 88 | |
| 89 | You can disable this check globally by adding this config block: |
| 90 | |
| 91 | ```js |
| 92 | checks { |
| 93 | disabled = ["alerts/count"] |
| 94 | } |
| 95 | ``` |
| 96 | |
| 97 | You can also disable it for all rules inside given file by adding |
| 98 | a comment anywhere in that file. Example: |
| 99 | |
| 100 | ```yaml |
| 101 | # pint file/disable alerts/count |
| 102 | ``` |
| 103 | |
| 104 | Or you can disable it per rule by adding a comment to it. Example: |
| 105 | |
| 106 | ```yaml |
| 107 | # pint disable alerts/count |
| 108 | ``` |
| 109 | |
| 110 | If you want to disable only individual instances of this check |
| 111 | you can add a more specific comment. |
| 112 | |
| 113 | ```yaml |
| 114 | # pint disable alerts/count($prometheus) |
| 115 | ``` |
| 116 | |
| 117 | Where `$prometheus` is the name of Prometheus server to disable. |
| 118 | |
| 119 | Example: |
| 120 | |
| 121 | ```yaml |
| 122 | # pint disable alerts/count(prod) |
| 123 | ``` |
| 124 | |
| 125 | ## How to snooze it |
| 126 | |
| 127 | You can disable this check until given time by adding a comment to it. Example: |
| 128 | |
| 129 | ```yaml |
| 130 | # pint snooze $TIMESTAMP alerts/count |
| 131 | ``` |
| 132 | |
| 133 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 134 | formatted or `YYYY-MM-DD`. |
| 135 | Adding this comment will disable `alerts/count` *until* `$TIMESTAMP`, after that |
| 136 | check will be re-enabled. |
| 137 | |