renge/prometheus: Use common relabel config for VPN

This commit is contained in:
Simon Bruder 2024-08-20 12:15:39 +02:00
parent 5245fa82d4
commit 69c4138459
Signed by: simon
GPG key ID: 347FF8699CDA0776

View file

@ -8,6 +8,12 @@ let
mkStaticTargets = targets: lib.singleton { inherit targets; }; mkStaticTargets = targets: lib.singleton { inherit targets; };
mkStaticTarget = target: mkStaticTargets (lib.singleton target); mkStaticTarget = target: mkStaticTargets (lib.singleton target);
relabelVpnConfig = {
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:[0-9]*";
};
in in
{ {
services.prometheus = { services.prometheus = {
@ -77,11 +83,7 @@ in
"yuzuru.vpn.sbruder.de:9100" "yuzuru.vpn.sbruder.de:9100"
"koyomi.vpn.sbruder.de:9100" "koyomi.vpn.sbruder.de:9100"
]; ];
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:9100";
};
} }
{ {
job_name = "smartctl"; job_name = "smartctl";
@ -93,11 +95,7 @@ in
"shinobu.vpn.sbruder.de:9633" "shinobu.vpn.sbruder.de:9633"
"koyomi.vpn.sbruder.de:9633" "koyomi.vpn.sbruder.de:9633"
]; ];
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:9633";
};
} }
{ {
job_name = "qbittorrent"; job_name = "qbittorrent";
@ -105,11 +103,7 @@ in
"fuuko.vpn.sbruder.de:9561" "fuuko.vpn.sbruder.de:9561"
"nazuna.vpn.sbruder.de:9561" "nazuna.vpn.sbruder.de:9561"
]; ];
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:9561";
};
} }
( (
let let
@ -128,10 +122,7 @@ in
{ {
job_name = "dnsmasq"; job_name = "dnsmasq";
static_configs = mkStaticTarget "shinobu.vpn.sbruder.de:${toString config.services.prometheus.exporters.dnsmasq.port}"; static_configs = mkStaticTarget "shinobu.vpn.sbruder.de:${toString config.services.prometheus.exporters.dnsmasq.port}";
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
replacement = "shinobu";
};
} }
{ {
job_name = "hcloud"; job_name = "hcloud";
@ -158,11 +149,7 @@ in
"okarin.vpn.sbruder.de:9433" "okarin.vpn.sbruder.de:9433"
"yuzuru.vpn.sbruder.de:9433" "yuzuru.vpn.sbruder.de:9433"
]; ];
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:9433";
};
} }
{ {
job_name = "snmp"; job_name = "snmp";
@ -193,11 +180,7 @@ in
static_configs = mkStaticTargets [ static_configs = mkStaticTargets [
"koyomi.vpn.sbruder.de:8404" "koyomi.vpn.sbruder.de:8404"
]; ];
relabel_configs = lib.singleton { relabel_configs = lib.singleton relabelVpnConfig;
target_label = "instance";
source_labels = lib.singleton "__address__";
regex = "(.*)\\.vpn\\.sbruder\\.de:8404";
};
} }
]; ];