nixos-config/configurations/host/waffentrager/services/monitoring.nix

60 lines
2.0 KiB
Nix
Raw Normal View History

2024-09-02 23:19:58 +02:00
{ materusArg, config, lib, ... }:
{
2024-09-03 10:12:23 +02:00
options.waffentragerService.monitoring.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable monitoring";
2024-09-02 23:19:58 +02:00
config =
let
2024-09-03 10:12:23 +02:00
cfg = config.waffentragerService.monitoring;
2024-09-02 23:19:58 +02:00
in
lib.mkIf cfg.enable {
services.grafana = {
dataDir = "${config.waffentragerService.elements.path}/services/grafana";
enable = true;
settings = {
server = {
# Listening Address
http_addr = "127.0.0.1";
# and Port
http_port = 3232;
# Grafana needs to know on which domain and URL it's running
domain = "watchman.materus.pl";
serve_from_sub_path = true;
};
};
};
2024-09-03 10:12:23 +02:00
services.prometheus = {
enable = true;
port = 3233;
globalConfig.scrape_interval = "30s";
2024-09-03 10:43:00 +02:00
stateDir = "elements/services/prometheus";
2024-09-03 10:12:23 +02:00
scrapeConfigs = [
{
job_name = "node";
static_configs = [{
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
];
};
services.prometheus.exporters.node = {
enable = true;
port = 3234;
enabledCollectors = [ "systemd" ];
extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ];
2024-09-03 10:43:00 +02:00
2024-09-03 10:12:23 +02:00
};
2024-09-02 23:19:58 +02:00
services.nginx.virtualHosts."watchman.materus.pl" = {
addSSL = true;
sslTrustedCertificate = "/var/lib/mnt_acme/materus.pl/chain.pem";
sslCertificateKey = "/var/lib/mnt_acme/materus.pl/key.pem";
sslCertificate = "/var/lib/mnt_acme/materus.pl/fullchain.pem";
http2 = false;
http3 = true;
locations."/" = {
proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}";
proxyWebsockets = true;
recommendedProxySettings = true;
};
};
};
}