Set up monitoring via Prometheus and Grafana

This commit is contained in:
coolneng 2023-03-23 07:43:07 +01:00
parent 231a4b663e
commit 4336861678
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 51 additions and 0 deletions

View File

@ -42,4 +42,41 @@ with pkgs;
};
};
# Metrics collection
services.prometheus = {
enable = true;
port = 9001;
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
zfs.enable = true;
wireguard.enable = true;
postgres.enable = true;
smartctl.enable = true;
#nginx.enable = true;
dnsmasq.enable = true;
};
scrapeConfigs = [{
job_name = "zion";
static_configs = [{
targets = [
"localhost:${toString config.services.prometheus.exporters.node.port}"
];
}];
}];
};
# Grafana configuration
services.grafana = {
enable = true;
settings.server = {
domain = "grafana.coolneng.duckdns.org";
http_port = 9009;
http_addr = "127.0.0.1";
};
};
}

View File

@ -49,6 +49,12 @@
add_header Access-Control-Allow-Origin * always;
'';
};
"/nginx_status/".extraConfig = ''
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
'';
};
};
"radicale.coolneng.duckdns.org" = {
@ -150,6 +156,14 @@
'';
};
};
"grafana.coolneng.duckdns.org" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:9009/";
proxyWebsockets = true;
};
};
};
};