cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.1.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/examples/config.hcl

130lines · modecode

1# Define "prod" Prometheus instance that will only be used for
2# rules defined in file matching "alerting/prod/.+" or "recording/prod/.+".
3prometheus "prod" {
4 uri = "https://prod.example.com"
5 timeout = "30s"
6
7 paths = [
8 "alerting/prod/.+",
9 "recording/prod/.+",
10 ]
11}
12
13# Define "dev" Prometheus instance that will be use for all rule checks.
14prometheus "dev" {
15 uri = "https://dev.example.com"
16 timeout = "60s"
17}
18
19rule {
20 # Disallow spaces in label/annotation keys, they're only allowed in values.
21 reject ".* +.*" {
22 label_keys = true
23 annotation_keys = true
24 }
25
26 # Disallow URLs in labels, they should go to annotations.
27 reject "https?://.+" {
28 label_keys = true
29 label_values = true
30 }
31}
32
33rule {
34 # This block will apply to all alerting rules.
35 match {
36 kind = "alerting"
37 }
38
39 # Each alert must have a 'summary' annotation on every alert.
40 annotation "summary" {
41 severity = "bug"
42 required = true
43 }
44
45 # Each alert must have a 'dashboard' annotation that links to grafana.
46 annotation "dashboard" {
47 severity = "bug"
48 value = "https://grafana.example.com/(.+)"
49 }
50
51 # Each alert must have a 'severity' annotation that's either 'critical' or 'warning'.
52 label "severity" {
53 severity = "bug"
54 value = "(critical|warning)"
55 required = true
56 }
57
58 # Check how many times each alert would fire in the last 1d.
59 alerts {
60 range = "1d"
61 step = "1m"
62 resolve = "5m"
63 }
64
65 # Check if templates used in annotations and labels are valid.
66 template {}
67}
68
69rule {
70 # This block will apply to all alerting rules with severity="critical" label set.
71 match {
72 kind = "alerting"
73
74 label "severity" {
75 value = "critical"
76 }
77 }
78
79 # All severity="critical" alerts must have a runbook link as annotation.
80 annotation "runbook" {
81 severity = "bug"
82 value = "https://runbook.example.com/.+"
83 required = true
84 }
85}
86
87rule {
88 # This block will apply to all recording rules.
89 match {
90 kind = "recording"
91 }
92
93 # Ensure that all aggregations are preserving "job" label.
94 aggregate ".+" {
95 severity = "bug"
96 keep = ["job"]
97 }
98
99 # Enable series check that will warn if alert rules are using time series
100 # not present in any of configured Prometheus servers.
101 series {}
102
103 # Enable cost checks that will print the number of returned time series and try
104 # to estimate total memory usage assuming that each series require 4KB of memory.
105 cost {
106 bytesPerSample = 4096
107 }
108}
109
110rule {
111 # This block will apply to all recording rules in "recording/federation" directory.
112 match {
113 kind = "recording"
114 path = "recording/federation/.+"
115 }
116
117 # All recording rules named "cluster:.+" must strip "instance" label when aggregating.
118 # Example rule that would raise a linter error:
119 # - record: cluster:http_requests:rate5m
120 # expr: sum(rate(http_requests_total[5m])) by (job, instance)
121 # Rules that would be allowed:
122 # - record: cluster:http_requests:rate5m
123 # expr: sum(rate(http_requests_total[5m])) by (job)
124 # - record: cluster:http_requests:rate5m
125 # expr: sum(rate(http_requests_total[5m]))
126 aggregate "cluster:.+" {
127 severity = "bug"
128 strip = ["instance"]
129 }
130}
131