ping: relabel

This commit is contained in:
Motiejus Jakštys 2024-09-16 15:10:54 +03:00
parent 77b5094616
commit 550d1c05e1
1 changed files with 23 additions and 16 deletions

View File

@ -344,24 +344,31 @@ in
scrapeConfigs = scrapeConfigs =
[ [
{
job_name = "ping";
static_configs = [
( (
let let
port = toString config.services.prometheus.exporters.ping.port; port = toString config.services.prometheus.exporters.ping.port;
hosts = [
"fwminex.servers.jakst"
"fra1-b.servers.jakst"
"vno1-gdrx.motiejus.jakst"
];
in in
{ {
targets = [ job_name = "ping";
"127.0.0.1:${port}" relabel_configs = map (hostname: {
"${myData.hosts."fwminex.servers.jakst".jakstIP}:${port}" source_labels = [ "__address__" ];
"${myData.hosts."fra1-b.servers.jakst".jakstIP}:${port}" regex = "${myData.hosts.${hostname}.jakstIP}:${port}";
"${myData.hosts."vno1-gdrx.motiejus.jakst".jakstIP}:${port}" replacement = "${hostname}:${port}";
target_label = "__address__";
}) hosts;
static_configs = [
{
targets = [ "127.0.0.1:${port}" ] ++ map (host: "${myData.hosts.${host}.jakstIP}:${port}") hosts;
}
]; ];
} }
) )
];
}
{ {
job_name = "prometheus"; job_name = "prometheus";
static_configs = [ { targets = [ "127.0.0.1:${toString myData.ports.prometheus}" ]; } ]; static_configs = [ { targets = [ "127.0.0.1:${toString myData.ports.prometheus}" ]; } ];