cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/alerts/count.md
86lines · 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` is set on alerts it will be used to adjust results. |
| 13 | |
| 14 | In some cases queries might fail due to timeout or loading too many samples. |
| 15 | This check will try to retry such queries with a shorter `range` until it |
| 16 | gets a response. |
| 17 | |
| 18 | ## Configuration |
| 19 | |
| 20 | Syntax: |
| 21 | |
| 22 | ```js |
| 23 | alerts { |
| 24 | range = "1h" |
| 25 | step = "1m" |
| 26 | resolve = "5m" |
| 27 | } |
| 28 | ``` |
| 29 | |
| 30 | - `range` - query range, how far to look back, `1h` would mean that pint will |
| 31 | query last 1h of metrics. If a query results in a timeout pint will retry it |
| 32 | with 50% smaller range until it succeeds. |
| 33 | Defaults to `1d`. |
| 34 | - `step` - query resolution, for most accurate result use step equal |
| 35 | to `scrape_interval`, try to reduce it if that would load too many samples. |
| 36 | Defaults to `1m`. |
| 37 | - `resolve` - duration after which stale alerts are resolved. Defaults to `5m`. |
| 38 | |
| 39 | ## How to enable it |
| 40 | |
| 41 | This check is not enabled by default as it requires explicit configuration |
| 42 | to work. |
| 43 | To enable it add one or more `prometheus {...}` blocks and a `rule {...}` block |
| 44 | with this checks config. |
| 45 | |
| 46 | Example: |
| 47 | |
| 48 | ```js |
| 49 | prometheus "prod" { |
| 50 | uri = "https://prometheus-prod.example.com" |
| 51 | timeout = "60s" |
| 52 | } |
| 53 | |
| 54 | rule { |
| 55 | alerts { |
| 56 | range = "1d" |
| 57 | step = "1m" |
| 58 | resolve = "5m" |
| 59 | } |
| 60 | } |
| 61 | ``` |
| 62 | |
| 63 | ## How to disable it |
| 64 | |
| 65 | You can disable this check globally by adding this config block: |
| 66 | |
| 67 | ```js |
| 68 | checks { |
| 69 | disabled = ["alerts/count"] |
| 70 | } |
| 71 | ``` |
| 72 | |
| 73 | Or you can disable it per rule by adding a comment to it. |
| 74 | |
| 75 | `# pint disable alerts/count` |
| 76 | |
| 77 | If you want to disable only individual instances of this check |
| 78 | you can add a more specific comment. |
| 79 | |
| 80 | `# pint disable alerts/count($prometheus)` |
| 81 | |
| 82 | Where `$prometheus` is the name of Prometheus server to disable. |
| 83 | |
| 84 | Example: |
| 85 | |
| 86 | `# pint disable alerts/count(prod)` |
| 87 | |