cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
41f437789877e1c4101a43d8bac1e052dae0448b

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/examples/config.hcl

131lines · 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 '{{ $value }}'/'{{ .Value }}' is used in labels
66 # https://www.robustperception.io/dont-put-the-value-in-alert-labels
67 value {}
68}
69
70rule {
71 # This block will apply to all alerting rules with severity="critical" label set.
72 match {
73 kind = "alerting"
74
75 label "severity" {
76 value = "critical"
77 }
78 }
79
80 # All severity="critical" alerts must have a runbook link as annotation.
81 annotation "runbook" {
82 severity = "bug"
83 value = "https://runbook.example.com/.+"
84 required = true
85 }
86}
87
88rule {
89 # This block will apply to all recording rules.
90 match {
91 kind = "recording"
92 }
93
94 # Ensure that all aggregations are preserving "job" label.
95 aggregate ".+" {
96 severity = "bug"
97 keep = ["job"]
98 }
99
100 # Enable series check that will warn if alert rules are using time series
101 # not present in any of configured Prometheus servers.
102 series {}
103
104 # Enable cost checks that will print the number of returned time series and try
105 # to estimate total memory usage assuming that each series require 4KB of memory.
106 cost {
107 bytesPerSample = 4096
108 }
109}
110
111rule {
112 # This block will apply to all recording rules in "recording/federation" directory.
113 match {
114 kind = "recording"
115 path = "recording/federation/.+"
116 }
117
118 # All recording rules named "cluster:.+" must strip "instance" label when aggregating.
119 # Example rule that would raise a linter error:
120 # - record: cluster:http_requests:rate5m
121 # expr: sum(rate(http_requests_total[5m])) by (job, instance)
122 # Rules that would be allowed:
123 # - record: cluster:http_requests:rate5m
124 # expr: sum(rate(http_requests_total[5m])) by (job)
125 # - record: cluster:http_requests:rate5m
126 # expr: sum(rate(http_requests_total[5m]))
127 aggregate "cluster:.+" {
128 severity = "bug"
129 strip = ["instance"]
130 }
131}
132