1
0

hosts/monitoring-3: use primary fqdn for instance label in prometheus

This commit is contained in:
clerie 2023-01-05 22:02:48 +01:00
parent 1dfba9663a
commit 30e22dff8d

View File

@ -131,7 +131,14 @@ in {
services.prometheus = { services.prometheus = {
enable = true; enable = true;
listenAddress = "[::1]"; listenAddress = "[::1]";
scrapeConfigs = [ scrapeConfigs = let
relabelAddressToInstance = {
source_labels = [ "__address__" ];
target_label = "instance";
regex = ''([\w-]+)\.mon\.clerie\.de\:\d+'';
replacement = "\${1}.net.clerie.de";
};
in [
{ {
job_name = "prometheus"; job_name = "prometheus";
scrape_interval = "20s"; scrape_interval = "20s";
@ -143,6 +150,9 @@ in {
]; ];
} }
]; ];
relabel_configs = [
relabelAddressToInstance
];
} }
{ {
job_name = "node-exporter"; job_name = "node-exporter";
@ -155,6 +165,9 @@ in {
++ monitoringTargets; ++ monitoringTargets;
} }
]; ];
relabel_configs = [
relabelAddressToInstance
];
} }
{ {
job_name = "nixos-exporter"; job_name = "nixos-exporter";
@ -164,6 +177,9 @@ in {
targets = nixosMonitoringTargets; targets = nixosMonitoringTargets;
} }
]; ];
relabel_configs = [
relabelAddressToInstance
];
} }
{ {
job_name = "bird-exporter"; job_name = "bird-exporter";
@ -173,6 +189,9 @@ in {
targets = birdMonitoringTargets; targets = birdMonitoringTargets;
} }
]; ];
relabel_configs = [
relabelAddressToInstance
];
} }
{ {
job_name = "blackbox_icmp6"; job_name = "blackbox_icmp6";
@ -211,10 +230,7 @@ in {
target_label = "__address__"; target_label = "__address__";
replacement = "\${1}"; replacement = "\${1}";
} }
{ relabelAddressToInstance
source_labels = [ "__address__" ];
target_label = "instance";
}
]; ];
} }
{ {
@ -255,10 +271,7 @@ in {
target_label = "__address__"; target_label = "__address__";
replacement = "\${1}"; replacement = "\${1}";
} }
{ relabelAddressToInstance
source_labels = [ "__address__" ];
target_label = "instance";
}
]; ];
} }
{ {
@ -297,6 +310,9 @@ in {
]; ];
} }
]; ];
relabel_configs = [
relabelAddressToInstance
];
} }
]; ];
alertmanagers = [ alertmanagers = [