cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/examples/prometheus_discovery_query.hcl
30lines · modecode
| 1 | # Example of Prometheus server discovery using a PromQL query. |
| 2 | # This is useful when Prometheus instances are registered in a service |
| 3 | # discovery system and their addresses are available as metrics. |
| 4 | |
| 5 | discovery { |
| 6 | # Query an existing Prometheus server to discover other Prometheus instances. |
| 7 | prometheusQuery { |
| 8 | uri = "https://prometheus-discovery.example.com" |
| 9 | timeout = "2m" |
| 10 | |
| 11 | # The PromQL query must return time series with labels we can use |
| 12 | # in the template below. Here we assume each Prometheus instance |
| 13 | # exposes a 'prometheus_build_info' metric with an 'instance' label. |
| 14 | query = "prometheus_build_info" |
| 15 | |
| 16 | template { |
| 17 | # Use the 'instance' label from query results as the server name. |
| 18 | name = "{{ $instance }}" |
| 19 | |
| 20 | # Build the URI from the discovered instance label. |
| 21 | uri = "https://{{ $instance }}" |
| 22 | |
| 23 | # Tag all discovered servers so they can be referenced together. |
| 24 | tags = ["discovered"] |
| 25 | |
| 26 | # Only check rules that belong to this discovered Prometheus. |
| 27 | include = ["rules/{{ $instance }}/.+"] |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |