Prometheus pushgateway

This commit is contained in:
Andrea Ciceri 2024-07-25 16:44:28 +02:00
parent 2871c291bf
commit a39a314e4c
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
2 changed files with 112 additions and 26 deletions

View file

@ -1,9 +1,14 @@
{ {
config, config,
pkgs, pkgs,
lib,
... ...
}: { }: let
services.prometheus.exporters.node = { hostname = config.networking.hostName;
mkFor = hosts: lib.mkIf (builtins.elem hostname hosts);
in {
services.prometheus.exporters = {
node = mkFor ["sisko" "picard"] {
enable = true; enable = true;
enabledCollectors = [ enabledCollectors = [
"cpu" "cpu"
@ -29,4 +34,23 @@
]; ];
extraFlags = ["--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi"]; extraFlags = ["--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi"];
}; };
wireguard = mkFor ["sisko" "picard"] {
enable = true;
};
zfs = mkFor ["picard"] {
enable = true;
};
# restic = mkFor ["sisko"] {
# enable = true;
# };
postgres = mkFor ["sisko"] {
enable = true;
};
nginx = mkFor ["sisko"] {
enable = true;
};
smartctl = mkFor ["sisko"] {
enable = true;
};
};
} }

View file

@ -3,6 +3,12 @@
in { in {
services.prometheus = { services.prometheus = {
enable = true; enable = true;
pushgateway = {
enable = true;
web = {
listen-address = "sisko.fleet:9094";
};
};
checkConfig = false; # Otherwise it will fail because it cannot access bearer_token_file checkConfig = false; # Otherwise it will fail because it cannot access bearer_token_file
webExternalUrl = "https://status.aciceri.dev"; webExternalUrl = "https://status.aciceri.dev";
globalConfig.scrape_interval = "10s"; globalConfig.scrape_interval = "10s";
@ -17,6 +23,14 @@ in {
} }
]; ];
} }
{
job_name = "pushgateway";
static_configs = [
{
targets = [cfg.pushgateway.web.listen-address];
}
];
}
{ {
job_name = "node"; job_name = "node";
static_configs = [ static_configs = [
@ -25,6 +39,54 @@ in {
} }
]; ];
} }
{
job_name = "wireguard";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9586") ["picard"];
}
];
}
{
job_name = "zfs";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9134") ["picard"];
}
];
}
{
job_name = "restic";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9753") ["sisko"];
}
];
}
{
job_name = "postgres";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9187") ["sisko"];
}
];
}
{
job_name = "nginx";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9117") ["sisko"];
}
];
}
{
job_name = "smartctl";
static_configs = [
{
targets = builtins.map (host: "${host}.fleet:9633") ["sisko"];
}
];
}
]; ];
}; };
environment.persistence."/persist".directories = [ environment.persistence."/persist".directories = [