cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/rule/dependency.md
87lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # rule/dependency |
| 8 | |
| 9 | This check only works when running `pint ci` and will validate that any |
| 10 | removed recording rule isn't still being used by other rules. |
| 11 | |
| 12 | Removing any recording rule that is a dependency of other rules is likely |
| 13 | to make them stop working, unless there's some other source of the metric |
| 14 | that was produced by the removed rule. |
| 15 | |
| 16 | Example: consider this two rules, one generates `down:count` metric |
| 17 | that is then used by the alert rule: |
| 18 | |
| 19 | ```yaml |
| 20 | groups: |
| 21 | - name: ... |
| 22 | rules: |
| 23 | - record: down:count |
| 24 | expr: count(up == 0) by(job) |
| 25 | - alert: Job is down |
| 26 | expr: down:count > 0 |
| 27 | ``` |
| 28 | |
| 29 | If we were to edit this file and delete the recording rule: |
| 30 | |
| 31 | ```yaml |
| 32 | groups: |
| 33 | - name: ... |
| 34 | rules: |
| 35 | - alert: Job is down |
| 36 | expr: down:count > 0 |
| 37 | ``` |
| 38 | |
| 39 | This would leave our alert rule broken because Prometheus would |
| 40 | no longer have `down:count` metric. |
| 41 | |
| 42 | This check tries to detect scenarios like this but works across all |
| 43 | files. |
| 44 | |
| 45 | ## Configuration |
| 46 | |
| 47 | This check doesn't have any configuration options. |
| 48 | |
| 49 | ## How to enable it |
| 50 | |
| 51 | This check is enabled by default. |
| 52 | |
| 53 | ## How to disable it |
| 54 | |
| 55 | You can disable this check globally by adding this config block: |
| 56 | |
| 57 | ```js |
| 58 | checks { |
| 59 | disabled = ["rule/dependency"] |
| 60 | } |
| 61 | ``` |
| 62 | |
| 63 | You can also disable it for all rules inside given file by adding |
| 64 | a comment anywhere in that file. Example: |
| 65 | |
| 66 | ```yaml |
| 67 | # pint file/disable rule/dependency |
| 68 | ``` |
| 69 | |
| 70 | Or you can disable it per rule by adding a comment to it. Example: |
| 71 | |
| 72 | ```yaml |
| 73 | # pint disable rule/dependency |
| 74 | ``` |
| 75 | |
| 76 | ## How to snooze it |
| 77 | |
| 78 | You can disable this check until given time by adding a comment to it. Example: |
| 79 | |
| 80 | ```yaml |
| 81 | # pint snooze $TIMESTAMP rule/dependency |
| 82 | ``` |
| 83 | |
| 84 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 85 | formatted or `YYYY-MM-DD`. |
| 86 | Adding this comment will disable `rule/dependency` *until* `$TIMESTAMP`, after that |
| 87 | check will be re-enabled. |
| 88 | |