cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.44.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/promql/aggregate.md

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