grimm-nixos-laptop/modules/prometheus.nix

56 lines
1.5 KiB
Nix
Raw Normal View History

2024-05-08 21:50:08 +02:00
{ config, ... }:
2024-05-08 21:49:37 +02:00
let
inherit (config.networking) domain;
prometheus_host = "prometheus.${domain}";
prometheus_port = 9090; # netstat -nlp | grep 9090
2024-05-08 21:50:08 +02:00
in
{
security.acme.certs."${domain}".extraDomainNames = [ prometheus_host ];
2024-05-08 21:49:37 +02:00
services.prometheus = {
enable = true;
port = prometheus_port;
globalConfig.scrape_interval = "15s";
scrapeConfigs = [
{
job_name = "chrysalis";
2024-05-08 21:50:08 +02:00
static_configs = [
{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
"127.0.0.1:${toString config.services.prometheus.exporters.nginx.port}"
"127.0.0.1:${toString config.services.prometheus.exporters.postgres.port}"
];
}
];
2024-05-08 21:49:37 +02:00
}
];
exporters = {
nginx.enable = true;
redis.enable = true;
domain.enable = true;
postgres.enable = true;
nginxlog.enable = true;
jitsi.enable = true;
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
};
};
services.nginx = {
enable = true;
virtualHosts."${prometheus_host}" = {
serverName = prometheus_host;
forceSSL = true;
useACMEHost = domain;
locations."/" = {
2024-05-08 21:50:08 +02:00
# proxyPass = "http://127.0.0.1:${builtins.toString config.services.prometheus.port}";
2024-05-08 21:49:37 +02:00
return = "307 https://${domain}"; # nuh uh, no raw prometheus access for you!
};
};
};
}