monitoring: alert on unknown servers in the Hetzner project
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:
Sergei Poljanski 2026-11-16 00:13:00 +04:00
commit ebd4f110f4
Signed by: asxpi
GPG key ID: 4F8851660FA4121B

View file

@ -255,6 +255,38 @@ groups:
for: 2m
labels: { severity: critical }
annotations: { summary: "{{ $labels.ip }} answers on the VPC (seen from {{ $labels.host }}) and is not in security_vpc_hosts" }
- uid: sec-hcloud-server-unknown
title: "Unknown server in the Hetzner project"
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: prometheus
model: { refId: A, expr: "up{job=\"hcloud\",known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
- refId: C
datasourceUid: __expr__
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
noDataState: OK
execErrState: Error
for: 2m
labels: { severity: critical }
annotations: { summary: "Server {{ $labels.server }} ({{ $labels.type }}, {{ $labels.public_ip }}, private {{ $labels.private_ip }}) exists in the Hetzner project and is not in monitoring_hcloud_servers" }
- uid: sec-hcloud-inventory-stale
title: "Hetzner server list not updating"
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: prometheus
model: { refId: A, expr: "absent(up{job=\"hcloud\"}) or increase(prometheus_sd_refresh_failures_total{mechanism=\"hetzner\"}[30m]) > 3", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
- refId: C
datasourceUid: __expr__
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
noDataState: OK
execErrState: Error
for: 10m
labels: { severity: critical }
annotations: { summary: "Prometheus cannot list the servers of the Hetzner project (token revoked or API unreachable): new servers go unnoticed" }
- uid: sec-user-unknown
title: "Unknown login account"
condition: C