dots/hosts/luna/modules/monitoring/prometheus.nix
Price Hiller 02334f5601
All checks were successful
Check Formatting of Files / Check-Formatting (push) Successful in 1m14s
refactor!: the big nix refactor
2024-05-03 14:35:00 -05:00

98 lines
2.1 KiB
Nix

{
config,
fqdn,
pkgs,
...
}:
let
prometheus_host = "prometheus.${fqdn}";
in
{
services = {
prometheus = {
enable = true;
port = 9000;
scrapeConfigs = [
{
job_name = "node-exporter";
static_configs = [
{ targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
];
exporters = {
node = {
enable = true;
port = 9001;
enabledCollectors = [
"arp"
"bcache"
"btrfs"
"bonding"
"cpu"
"cpufreq"
"diskstats"
"edac"
"entropy"
"fibrechannel"
"filefd"
"filesystem"
"hwmon"
"ipvs"
"loadavg"
"meminfo"
"mdadm"
"netclass"
"netdev"
"netstat"
"nfs"
"nfsd"
"nvme"
"os"
"powersupplyclass"
"pressure"
"rapl"
"schedstat"
"sockstat"
"softnet"
"stat"
"thermal_zone"
"time"
"udp_queues"
"uname"
"vmstat"
"systemd"
];
};
};
};
nginx = {
additionalModules = [ pkgs.nginxModules.pam ];
virtualHosts."${prometheus_host}" = {
enableACME = true;
forceSSL = true;
extraConfig = ''
auth_pam "Password Required";
auth_pam_service_name "nginx";
'';
locations."/" = {
proxyPass = "http://${config.services.prometheus.listenAddress}:${builtins.toString config.services.prometheus.port}";
};
};
};
};
security.pam.services.nginx.setEnvironment = false;
systemd.services.nginx.serviceConfig = {
SupplementaryGroups = [ "shadow" ];
};
environment.persistence.save.directories = [
{
directory = "/var/lib/${config.services.prometheus.stateDir}";
user = "prometheus";
group = "prometheus";
}
];
}