prometheus-scrape-target-labels #30
Reference in New Issue
Block a user
Delete Branch "prometheus-scrape-target-labels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Propagate
homelab.hostmetadata to Prometheus scrape targets, enabling semantic alert filtering using labels instead of hardcoded instance names.Changes
New Labels
All Prometheus scrape targets now include:
hostnamens1,monitoring01) - always presentroledns,build-host,vault) - when configuredtiertestfor test VMs) - when non-defaultdns_roleprimaryorsecondaryfor DNS serversExample Queries
Alert Rule Updates
high_cpu_load: Now usesrole!="build-host"instead of hardcodedinstance!="nix-cache01..."unbound_low_cache_hit_ratio: Now filters bydns_role="primary"to avoid alerting on secondary DNSVerified
Deployed to monitoring01 and confirmed labels are working in Prometheus.
Add a `hostname` label to all Prometheus scrape targets, making it easy to query all metrics for a host without wildcarding the instance label. Example queries: - {hostname="ns1"} - all metrics from ns1 - node_cpu_seconds_total{hostname="monitoring01"} - specific metric For external targets (like gunter), the hostname is extracted from the target string. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>