monitoring: alert on unknown servers in the Hetzner project
Some checks failed
deploy / ansible (push) Failing after 41s
Some checks failed
deploy / ansible (push) Failing after 41s
The VPC ping sweep misses a server that drops ICMP or is not attached to the private network. Prometheus now lists the project's servers from the Hetzner API with a read-only token and marks each one known or not against monitoring_hcloud_servers. Nothing is scraped from the servers: every discovered target is Prometheus itself with all samples dropped, which leaves one `up` series per server. A second alert fires when the list stops updating, so a revoked token does not silently disable the check. Assisted-by: Claude:fable-5-2
This commit is contained in:
parent
56dd0255dc
commit
ebd4f110f4
1 changed files with 381 additions and 190 deletions
|
|
@ -54,6 +54,40 @@ scrape_configs:
|
|||
- targets: ["localhost:9090", "loki:3100", "grafana:3000", "blackbox:9115"]
|
||||
labels: { host: asxpio-ops }
|
||||
|
||||
# Servers in the Hetzner project, from the API (read-only token). Nothing
|
||||
# is scraped from them: every target is Prometheus itself with all
|
||||
# samples dropped, which leaves one `up` series per server.
|
||||
- job_name: hcloud
|
||||
scrape_interval: 60s
|
||||
hetzner_sd_configs:
|
||||
- role: hcloud
|
||||
authorization:
|
||||
credentials: "{{ monitoring_hcloud_token }}"
|
||||
relabel_configs:
|
||||
- source_labels: [__meta_hetzner_server_name]
|
||||
target_label: server
|
||||
- source_labels: [__meta_hetzner_server_name]
|
||||
target_label: instance
|
||||
- source_labels: [__meta_hetzner_public_ipv4]
|
||||
target_label: public_ip
|
||||
- regex: __meta_hetzner_hcloud_private_ipv4_.+
|
||||
action: labelmap
|
||||
replacement: private_ip
|
||||
- source_labels: [__meta_hetzner_hcloud_server_type]
|
||||
target_label: type
|
||||
- source_labels: [__meta_hetzner_server_status]
|
||||
target_label: status
|
||||
- target_label: known
|
||||
replacement: "false"
|
||||
- source_labels: [__meta_hetzner_server_name]
|
||||
regex: '{{ monitoring_hcloud_servers | map("regex_escape") | join("|") }}'
|
||||
target_label: known
|
||||
replacement: "true"
|
||||
- target_label: __address__
|
||||
replacement: localhost:9090
|
||||
metric_relabel_configs:
|
||||
- action: drop
|
||||
|
||||
{% for module in monitoring_probes | map(attribute='module') | unique %}
|
||||
- job_name: probe_{{ module }}
|
||||
metrics_path: /probe
|
||||
|
|
|
|||
Loading…
Reference in a new issue