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