cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ae4e045f94eb733fa451c4c87282fdde668508f7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/ignoring.md

179lines · modecode

1---
2layout: default
3title: Ignoring problems
4parent: Documentation
5nav_order: 2
6---
7
8# Ignoring selected lines or files
9
10While parsing files pint will look for special comment blocks and use them to
11exclude some parts or whole files from checks.
12
13## Ignoring whole files
14
15Add a `# pint ignore/file` comment on top of the file, everything below that line
16will be ignored.
17
18Example:
19
20```yaml
21# pint ignore/file
22
23groups:
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
32To ignore just one line use `# pint ignore/line` at the end of that line or
33`# ignore/next-line` on the line before.
34This is useful if you're linting templates used to generate Prometheus
35configuration and it contains some extra lines that are not valid YAML.
36
37Example:
38
39{% raw %}
40
41```yaml
42{% set some_jinja_var1 = "bar" %} # pint ignore/line
43groups:
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
57To ignore a part of a file wrap it with `# pint ignore/begin` and
58`# pint ignore/end` comments.
59
60Example:
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
70groups:
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
81To disable specific check globally, for all files and rules, add it to pint configuration
82file. Syntax:
83
84```js
85checks {
86 disabled = [ "...", ... ]
87}
88```
89
90Example:
91
92```js
93checks {
94 disabled = ["alerts/template"]
95}
96```
97
98## Disabling individual checks for specific files
99
100To disable individual check for a specific rule use `# pint file/disable ...` comments
101anywhere in the file. This will disable given check for all rules in that file.
102
103See each individual [check](checks/index.md) documentation for details.
104
105You can also use tags set on Prometheus configuration blocks inside comments.
106Tags must use `+` prefix, so if you want to disable `promql/series` check on all
107Prometheus 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
115To disable individual check for a specific rule use `# pint disable ...` comments.
116A single comment can only disable one check, so repeat it for every check you wish
117to disable.
118
119See each individual [check](checks/index.md) documentation for details.
120
121Checks can also be disabled for specific Prometheus servers using
122`# pint disable ...($prometheus)` comments. Replace `$prometheus` with the name
123of the Prometheus configuration block in pint that you want to disable it for.
124Examples:
125
126If you have a `stating` Prometheus configuration block in pint config file:
127
128```js
129prometheus "staging" {
130 uri = "https://prometheus-staging.example.com"
131 tags = ["testing"]
132}
133```
134
135and have a rule where you want to disable `promql/series` checks run against that
136Prometheus server then add a comment:
137
138```yaml
139# pint disable promql/series(staging)
140```
141
142You can also use tags set on Prometheus configuration blocks inside comments.
143Tags must use `+` prefix, so if you want to disable `promql/series` check on all
144Prometheus servers with `testing` tag then add this comment:
145
146```yaml
147# pint disable promql/series(+testing)
148```
149
150## Snoozing checks
151
152If you want to disable some checks just for some time then you can snooze them
153instead of disabling forever.
154
155The difference between `# pint disable ...` and `# pint snooze ...` comments is that
156the snooze comment must include a timestamp. Selected check will be disabled *until*
157that timestamp.
158Timestamp must either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) syntax
159or `YYYY-MM-DD` (if you don't care about time and want to snooze until given date).
160Examples:
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
169Just 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
178If you want to snooze some checks for the entire file then you can use
179`# pint file/snooze ...` comment anywhere in given file.