cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.34.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/promql/aggregate.md

115lines · 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`# pint file/disable promql/aggregate`
93
94Or you can disable it per rule by adding a comment to it. Example:
95
96`# pint disable promql/aggregate`
97
98If you want to disable only individual instances of this check
99you can add a more specific comment.
100
101### If `keep` is set
102
103`# pint disable promql/aggregate($label:true)`
104
105Example:
106
107`# pint disable promql/aggregate(job:true)`
108
109### If `strip` is set
110
111`# pint disable promql/aggregate($label:false)`
112
113Example:
114
115`# pint disable promql/aggregate(instance:true)`
116