flake/nixos/profiles/prometheus/default.nix

51 lines
1.3 KiB
Nix
Raw Normal View History

2024-08-31 02:15:09 +00:00
{ config, lib, ... }:
2024-08-29 17:42:37 +00:00
{
services.prometheus.exporters.node = {
enable = true;
listenAddress = "127.0.0.1";
port = 9091;
enabledCollectors = [ "systemd" ];
};
2024-08-31 02:15:09 +00:00
services.caddy.settings.apps.http.servers.srv0.metrics = { };
services.caddy.settings.apps.http.servers.srv0.routes = [
{
match = lib.singleton {
host = [ config.networking.fqdn ];
path = [ "/metrics" ];
};
handle = [
{
handler = "authentication";
providers.http_basic.accounts = lib.singleton {
username = "prometheus";
password = "$2a$14$2Phk4tobM04H4XiGegB3TuEXkyORCKMKW8TptYPTPXUWmZgtGBj/.";
};
}
{
handler = "reverse_proxy";
upstreams = lib.singleton { dial = "127.0.0.1:9091"; };
}
];
}
{
match = lib.singleton {
host = [ config.networking.fqdn ];
path = [ "/caddy" ];
};
handle = [
{
handler = "authentication";
providers.http_basic.accounts = lib.singleton {
username = "prometheus";
password = "$2a$14$2Phk4tobM04H4XiGegB3TuEXkyORCKMKW8TptYPTPXUWmZgtGBj/.";
};
}
{
handler = "metrics";
}
];
}
];
2024-08-29 17:42:37 +00:00
}