cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/ignoring.md
179lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | title: Ignoring problems |
| 4 | parent: Documentation |
| 5 | nav_order: 2 |
| 6 | --- |
| 7 | |
| 8 | # Ignoring selected lines or files |
| 9 | |
| 10 | While parsing files pint will look for special comment blocks and use them to |
| 11 | exclude some parts or whole files from checks. |
| 12 | |
| 13 | ## Ignoring whole files |
| 14 | |
| 15 | Add a `# pint ignore/file` comment on top of the file, everything below that line |
| 16 | will be ignored. |
| 17 | |
| 18 | Example: |
| 19 | |
| 20 | ```yaml |
| 21 | # pint ignore/file |
| 22 | |
| 23 | groups: |
| 24 | - name: example |
| 25 | rules: |
| 26 | - record: job:http_inprogress_requests:sum |
| 27 | expr: sum by (job) (http_inprogress_requests) |
| 28 | ``` |
| 29 | |
| 30 | ## Ignoring individual lines |
| 31 | |
| 32 | To ignore just one line use `# pint ignore/line` at the end of that line or |
| 33 | `# ignore/next-line` on the line before. |
| 34 | This is useful if you're linting templates used to generate Prometheus |
| 35 | configuration and it contains some extra lines that are not valid YAML. |
| 36 | |
| 37 | Example: |
| 38 | |
| 39 | {% raw %} |
| 40 | |
| 41 | ```yaml |
| 42 | {% set some_jinja_var1 = "bar" %} # pint ignore/line |
| 43 | groups: |
| 44 | - name: example |
| 45 | rules: |
| 46 | - record: job:http_inprogress_requests:sum |
| 47 | expr: sum by (job) (http_inprogress_requests) |
| 48 | |
| 49 | # pint ignore/next-line |
| 50 | {% set some_jinja_var2 = "foo" %} |
| 51 | ``` |
| 52 | |
| 53 | {% endraw %} |
| 54 | |
| 55 | ## Ignoring a range of lines |
| 56 | |
| 57 | To ignore a part of a file wrap it with `# pint ignore/begin` and |
| 58 | `# pint ignore/end` comments. |
| 59 | |
| 60 | Example: |
| 61 | |
| 62 | {% raw %} |
| 63 | |
| 64 | ```yaml |
| 65 | # pint ignore/begin |
| 66 | {% set some_jinja_var1 = "bar" %} |
| 67 | {% set some_jinja_var2 = "foo" %} |
| 68 | # pint ignore/end |
| 69 | |
| 70 | groups: |
| 71 | - name: example |
| 72 | rules: |
| 73 | - record: job:http_inprogress_requests:sum |
| 74 | expr: sum by (job) (http_inprogress_requests) |
| 75 | ``` |
| 76 | |
| 77 | {% endraw %} |
| 78 | |
| 79 | ## Disabling checks globally |
| 80 | |
| 81 | To disable specific check globally, for all files and rules, add it to pint configuration |
| 82 | file. Syntax: |
| 83 | |
| 84 | ```js |
| 85 | checks { |
| 86 | disabled = [ "...", ... ] |
| 87 | } |
| 88 | ``` |
| 89 | |
| 90 | Example: |
| 91 | |
| 92 | ```js |
| 93 | checks { |
| 94 | disabled = ["alerts/template"] |
| 95 | } |
| 96 | ``` |
| 97 | |
| 98 | ## Disabling individual checks for specific files |
| 99 | |
| 100 | To disable individual check for a specific rule use `# pint file/disable ...` comments |
| 101 | anywhere in the file. This will disable given check for all rules in that file. |
| 102 | |
| 103 | See each individual [check](checks/index.md) documentation for details. |
| 104 | |
| 105 | You can also use tags set on Prometheus configuration blocks inside comments. |
| 106 | Tags must use `+` prefix, so if you want to disable `promql/series` check on all |
| 107 | Prometheus servers with `testing` tag then add this comment: |
| 108 | |
| 109 | ```yaml |
| 110 | # pint file/disable promql/series(+testing) |
| 111 | ``` |
| 112 | |
| 113 | ## Disabling individual checks for specific rules |
| 114 | |
| 115 | To disable individual check for a specific rule use `# pint disable ...` comments. |
| 116 | A single comment can only disable one check, so repeat it for every check you wish |
| 117 | to disable. |
| 118 | |
| 119 | See each individual [check](checks/index.md) documentation for details. |
| 120 | |
| 121 | Checks can also be disabled for specific Prometheus servers using |
| 122 | `# pint disable ...($prometheus)` comments. Replace `$prometheus` with the name |
| 123 | of the Prometheus configuration block in pint that you want to disable it for. |
| 124 | Examples: |
| 125 | |
| 126 | If you have a `stating` Prometheus configuration block in pint config file: |
| 127 | |
| 128 | ```js |
| 129 | prometheus "staging" { |
| 130 | uri = "https://prometheus-staging.example.com" |
| 131 | tags = ["testing"] |
| 132 | } |
| 133 | ``` |
| 134 | |
| 135 | and have a rule where you want to disable `promql/series` checks run against that |
| 136 | Prometheus server then add a comment: |
| 137 | |
| 138 | ```yaml |
| 139 | # pint disable promql/series(staging) |
| 140 | ``` |
| 141 | |
| 142 | You can also use tags set on Prometheus configuration blocks inside comments. |
| 143 | Tags must use `+` prefix, so if you want to disable `promql/series` check on all |
| 144 | Prometheus servers with `testing` tag then add this comment: |
| 145 | |
| 146 | ```yaml |
| 147 | # pint disable promql/series(+testing) |
| 148 | ``` |
| 149 | |
| 150 | ## Snoozing checks |
| 151 | |
| 152 | If you want to disable some checks just for some time then you can snooze them |
| 153 | instead of disabling forever. |
| 154 | |
| 155 | The difference between `# pint disable ...` and `# pint snooze ...` comments is that |
| 156 | the snooze comment must include a timestamp. Selected check will be disabled *until* |
| 157 | that timestamp. |
| 158 | Timestamp must either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) syntax |
| 159 | or `YYYY-MM-DD` (if you don't care about time and want to snooze until given date). |
| 160 | Examples: |
| 161 | |
| 162 | ```yaml |
| 163 | # pint snooze 2023-01-12T10:00:00Z promql/series |
| 164 | # pint snooze 2023-01-12 promql/rate |
| 165 | - record: ... |
| 166 | expr: ... |
| 167 | ``` |
| 168 | |
| 169 | Just like with `# pint disable ...` you can also use tags with snooze comments. |
| 170 | |
| 171 | ```yaml |
| 172 | # pint snooze 2023-01-12T10:00:00Z promql/series(+tag) |
| 173 | # pint snooze 2023-01-12 promql/rate(+tag) |
| 174 | - record: ... |
| 175 | expr: ... |
| 176 | ``` |
| 177 | |
| 178 | If you want to snooze some checks for the entire file then you can use |
| 179 | `# pint file/snooze ...` comment anywhere in given file. |