cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.75.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/promql/aggregate.md

143lines · modecode

1---
2layout: default
3parent: Checks
4grand_parent: Documentation
5---
6
7# promql/aggregate
8
9This check is used to inspect promql expressions and ensure that specific labels
10are kept or stripped away when aggregating results. It's mostly useful in recording
11rules.
12
13## Configuration
14
15Syntax:
16
17```js
18aggregate "$pattern" {
19 comment = "..."
20 severity = "bug|warning|info"
21 keep = [ "...", ... ]
22 strip = [ "...", ... ]
23}
24```
25
26- `$pattern` - regexp pattern to match rule name on, this can be templated
27 to reference checked rule fields, see [Configuration](../../configuration.md)
28 for details.
29- `comment` - set a custom comment that will be added to reported problems.
30- `severity` - set custom severity for reported issues, defaults to a warning.
31- `keep` - list of label names that must be preserved.
32- `strip` - list of label names that must be stripped.
33
34## How to enable it
35
36This check is not enabled by default as it requires explicit configuration
37to work.
38To enable it add one or more `rule {...}` blocks and specify all required
39rules there.
40
41Examples:
42
43Ensure that all series generated from recording rules have `job` labels preserved:
44
45```js
46rule {
47 match {
48 kind = "recording"
49 }
50 aggregate ".+" {
51 keep = ["job"]
52 comment = "`job` label must be kept on all aggregated metrics so we can link it with a scrape job"
53 }
54}
55```
56
57In some cases you might want to ensure that specific labels are removed in aggregations.
58For example in recording rules that are producing series consumed by federation, where
59only aggregated results (not per instance) are allowed:
60
61```js
62rule {
63 match {
64 kind = "recording"
65 }
66 aggregate "cluster:.+" {
67 strip = ["instance"]
68 }
69}
70```
71
72By default all issues found by this check will be reported as warnings. To adjust
73severity set a custom `severity` key:
74
75```js
76aggregate ".+" {
77 ...
78 severity = "bug"
79}
80```
81
82## How to disable it
83
84You can disable this check globally by adding this config block:
85
86```js
87checks {
88 disabled = ["promql/aggregate"]
89}
90```
91
92You can also disable it for all rules inside given file by adding
93a comment anywhere in that file. Example:
94
95```yaml
96# pint file/disable promql/aggregate
97```
98
99Or you can disable it per rule by adding a comment to it. Example:
100
101```yaml
102# pint disable promql/aggregate
103```
104
105If you want to disable only individual instances of this check
106you can add a more specific comment.
107
108### If `keep` is set
109
110```yaml
111# pint disable promql/aggregate($label:true)
112```
113
114Example:
115
116```yaml
117# pint disable promql/aggregate(job:true)
118```
119
120### If `strip` is set
121
122```yaml
123# pint disable promql/aggregate($label:false)
124```
125
126Example:
127
128```yaml
129# pint disable promql/aggregate(instance:false)
130```
131
132## How to snooze it
133
134You can disable this check until given time by adding a comment to it. Example:
135
136```yaml
137# pint snooze $TIMESTAMP promql/aggregate
138```
139
140Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339)
141formatted or `YYYY-MM-DD`.
142Adding this comment will disable `promql/aggregate` *until* `$TIMESTAMP`, after that
143check will be re-enabled.
144