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 | |
| 7 | paths = [ |
| 8 | "alerting/prod/.+", |
| 9 | "recording/prod/.+", |
| 10 | ] |
| 11 | } |
| 12 | |
| 13 | # Define "dev" Prometheus instance that will be use for all rule checks. |
| 14 | prometheus "dev" { |
| 15 | uri = "https://dev.example.com" |
| 16 | timeout = "60s" |
| 17 | } |
| 18 | |
| 19 | rule { |
| 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 | # Check if all queries use correct vector matching rules |
| 33 | vector_matching {} |
| 34 | } |
| 35 | |
| 36 | rule { |
| 37 | # This block will apply to all alerting rules. |
| 38 | match { |
| 39 | kind = "alerting" |
| 40 | } |
| 41 | |
| 42 | # Each alert must have a 'summary' annotation on every alert. |
| 43 | annotation "summary" { |
| 44 | severity = "bug" |
| 45 | required = true |
| 46 | } |
| 47 | |
| 48 | # Each alert must have a 'dashboard' annotation that links to grafana. |
| 49 | annotation "dashboard" { |
| 50 | severity = "bug" |
| 51 | value = "https://grafana.example.com/(.+)" |
| 52 | } |
| 53 | |
| 54 | # Each alert must have a 'severity' annotation that's either 'critical' or 'warning'. |
| 55 | label "severity" { |
| 56 | severity = "bug" |
| 57 | value = "(critical|warning)" |
| 58 | required = true |
| 59 | } |
| 60 | |
| 61 | # Check how many times each alert would fire in the last 1d. |
| 62 | alerts { |
| 63 | range = "1d" |
| 64 | step = "1m" |
| 65 | resolve = "5m" |
| 66 | } |
| 67 | |
| 68 | # Check if templates used in annotations and labels are valid. |
| 69 | template {} |
| 70 | } |
| 71 | |
| 72 | rule { |
| 73 | # This block will apply to all alerting rules with severity="critical" label set. |
| 74 | match { |
| 75 | kind = "alerting" |
| 76 | |
| 77 | label "severity" { |
| 78 | value = "critical" |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | # All severity="critical" alerts must have a runbook link as annotation. |
| 83 | annotation "runbook" { |
| 84 | severity = "bug" |
| 85 | value = "https://runbook.example.com/.+" |
| 86 | required = true |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | rule { |
| 91 | # This block will apply to all recording rules. |
| 92 | match { |
| 93 | kind = "recording" |
| 94 | } |
| 95 | |
| 96 | # Ensure that all aggregations are preserving "job" label. |
| 97 | aggregate ".+" { |
| 98 | severity = "bug" |
| 99 | keep = ["job"] |
| 100 | } |
| 101 | |
| 102 | # Enable series check that will warn if alert rules are using time series |
| 103 | # not present in any of configured Prometheus servers. |
| 104 | series {} |
| 105 | |
| 106 | # Enable cost checks that will print the number of returned time series and try |
| 107 | # to estimate total memory usage assuming that each series require 4KB of memory. |
| 108 | cost { |
| 109 | bytesPerSample = 4096 |
| 110 | } |
| 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 | |