cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.28.6

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/checks/query/cost.md

106lines · modecode

1---
2layout: default
3parent: Checks
4grand_parent: Documentation
5---
6
7# query/cost
8
9This check is used to calculate cost of a query and optionally report an issue
10if that cost is too high. It will run `expr` query from every rule against
11selected Prometheus servers and report results.
12This check can be used for both recording and alerting rules, but is most
13useful for recording rules.
14
15`pint` will try to estimate the number of bytes needed per single time series
16and use that to estimate the amount of memory needed for all time series
17returned by given query.
18The `bytes per time series` number is calculated using this query:
19
20```
21avg(avg_over_time(go_memstats_alloc_bytes[2h]) / avg_over_time(prometheus_tsdb_head_series[2h]))
22```
23
24Since Go uses garbage collector total Prometheus process memory will be more than the
25sum of all memory allocations, depending on many factors like memory pressure,
26Go version, GOGC settings etc. The estimate `pint` gives you should be considered
27`best case` scenario.
28
29## Configuration
30
31Syntax:
32
33```js
34cost {
35 severity = "bug|warning|info"
36 maxSeries = 5000
37}
38```
39
40- `severity` - set custom severity for reported issues, defaults to a warning.
41 This is only used when query result series exceed `maxSeries` value (if set).
42 If `maxSeries` is not set or when results count is below it pint will still
43 report it as information.
44- `maxSeries` - if set and number of results for given query exceeds this value
45 it will be reported as a bug (or custom severity if `severity` is set).
46
47## How to enable it
48
49This check is not enabled by default as it requires explicit configuration
50to work.
51To enable it add one or more `prometheus {...}` blocks and a `rule {...}` block
52with this checks config.
53
54Examples:
55
56All rules from files matching `rules/dev/.+` pattern will be tested against
57`dev` server. Results will be reported as information regardless of results.
58
59```js
60prometheus "dev" {
61 uri = "https://prometheus-dev.example.com"
62 timeout = "30s"
63 include = ["rules/dev/.+"]
64}
65
66rule {
67 cost {}
68}
69```
70
71## How to disable it
72
73You can disable this check globally by adding this config block:
74
75```js
76checks {
77 disabled = ["query/cost"]
78}
79```
80
81Or you can disable it per rule by adding a comment to it:
82
83`# pint disable query/cost`
84
85If you want to disable only individual instances of this check
86you can add a more specific comment.
87
88### If `maxSeries` is set
89
90`# pint disable query/cost($prometheus:$maxSeries)`
91
92Where `$prometheus` is the name of Prometheus server to disable.
93
94Example:
95
96`# pint disable query/cost(dev:5000)`
97
98### If `maxSeries` is NOT set
99
100`# pint disable query/cost($prometheus)`
101
102Where `$prometheus` is the name of Prometheus server to disable.
103
104Example:
105
106`# pint disable query/cost(dev)`
107