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

@ -102,8 +102,8 @@
},
{
"type": "stat",
"title": "VPC devices",
"description": "Addresses answering ping on the private network, not in security_vpc_hosts",
"title": "VPC devices, servers",
"description": "Addresses answering ping on the private network that are not in security_vpc_hosts, plus servers in the Hetzner project that are not in monitoring_hcloud_servers",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
@ -114,7 +114,7 @@
"type": "prometheus",
"uid": "prometheus"
},
"expr": "count(group by (ip) (security_vpc_host_info{known=\"false\"})) or vector(0)",
"expr": "(count(group by (ip) (security_vpc_host_info{known=\"false\"})) or vector(0)) + (count(up{job=\"hcloud\",known=\"false\"}) or vector(0))",
"refId": "A",
"instant": true,
"range": false
@ -885,6 +885,117 @@
},
"id": 13
},
{
"type": "table",
"title": "Hetzner project servers",
"description": "Servers the Hetzner API lists for the project, refreshed every minute. Catches a server that drops ping or is not attached to the VPC.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "group by (server, type, status, public_ip, private_ip, known) (up{job=\"hcloud\"})",
"refId": "A",
"instant": true,
"range": false,
"format": "table"
}
],
"gridPos": {
"h": 4,
"w": 24,
"x": 0,
"y": 14
},
"fieldConfig": {
"defaults": {
"custom": {
"filterable": true
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "known"
},
"properties": [
{
"id": "mappings",
"value": [
{
"type": "value",
"options": {
"true": {
"text": "yes",
"color": "green"
},
"false": {
"text": "NO",
"color": "red"
}
}
}
]
},
{
"id": "custom.cellOptions",
"value": {
"type": "color-background"
}
},
{
"id": "custom.width",
"value": 80
}
]
},
{
"matcher": {
"id": "byName",
"options": "Value"
},
"properties": [
{
"id": "custom.hidden",
"value": true
}
]
}
]
},
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"instance": true,
"job": true
},
"indexByName": {
"server": 0,
"type": 1,
"status": 2,
"public_ip": 3,
"private_ip": 4,
"known": 5
}
}
}
],
"options": {
"showHeader": true,
"cellHeight": "sm"
},
"id": 31
},
{
"type": "table",
"title": "Listening ports",
@ -910,7 +1021,7 @@
"h": 9,
"w": 24,
"x": 0,
"y": 14
"y": 18
},
"fieldConfig": {
"defaults": {
@ -1005,7 +1116,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 23
"y": 27
},
"panels": [],
"id": 15
@ -1035,7 +1146,7 @@
"h": 8,
"w": 8,
"x": 0,
"y": 24
"y": 28
},
"fieldConfig": {
"defaults": {
@ -1145,7 +1256,7 @@
"h": 8,
"w": 6,
"x": 8,
"y": 24
"y": 28
},
"fieldConfig": {
"defaults": {
@ -1254,7 +1365,7 @@
"h": 8,
"w": 10,
"x": 14,
"y": 24
"y": 28
},
"fieldConfig": {
"defaults": {
@ -1363,7 +1474,7 @@
"h": 7,
"w": 8,
"x": 0,
"y": 32
"y": 36
},
"fieldConfig": {
"defaults": {
@ -1488,7 +1599,7 @@
"h": 7,
"w": 6,
"x": 8,
"y": 32
"y": 36
},
"fieldConfig": {
"defaults": {
@ -1597,7 +1708,7 @@
"h": 7,
"w": 10,
"x": 14,
"y": 32
"y": 36
},
"fieldConfig": {
"defaults": {
@ -1689,7 +1800,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 39
"y": 43
},
"panels": [],
"id": 22
@ -1718,7 +1829,7 @@
"h": 7,
"w": 12,
"x": 0,
"y": 40
"y": 44
},
"fieldConfig": {
"defaults": {
@ -1772,7 +1883,7 @@
"h": 7,
"w": 12,
"x": 12,
"y": 40
"y": 44
},
"fieldConfig": {
"defaults": {
@ -1825,7 +1936,7 @@
"h": 9,
"w": 12,
"x": 0,
"y": 47
"y": 51
},
"options": {
"showTime": true,
@ -1859,7 +1970,7 @@
"h": 9,
"w": 12,
"x": 12,
"y": 47
"y": 51
},
"options": {
"showTime": true,
@ -1878,7 +1989,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 56
"y": 60
},
"panels": [],
"id": 27
@ -1908,7 +2019,7 @@
"h": 7,
"w": 8,
"x": 0,
"y": 57
"y": 61
},
"fieldConfig": {
"defaults": {
@ -1979,7 +2090,7 @@
"h": 7,
"w": 16,
"x": 8,
"y": 57
"y": 61
},
"fieldConfig": {
"defaults": {
@ -2042,7 +2153,7 @@
"h": 8,
"w": 24,
"x": 0,
"y": 64
"y": 68
},
"options": {
"showTime": true,
@ -2054,4 +2165,4 @@
"id": 30
}
]
}
}