nixos-config/nixos/machines/robi/prometheus.nix

55 lines
1.2 KiB
Nix
Raw Normal View History

2021-12-28 16:19:29 +01:00
{ config, pkgs, lib, ... }: {
services.nginx = {
enable = true;
statusPage = true;
virtualHosts = {
2023-02-08 00:19:09 +01:00
"prometheus.robi.private" = {
extraConfig = ''
allow ${config.tinc.private.subnet};
deny all;
'';
locations."/" = { proxyPass = "http://localhost:${toString config.services.prometheus.port}"; };
2021-12-28 16:19:29 +01:00
};
};
};
services.prometheus = {
enable = true;
# keep data for 30 days
extraFlags = [ "--storage.tsdb.retention.time=30d" ];
2023-02-08 00:19:09 +01:00
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
};
2021-12-28 16:19:29 +01:00
scrapeConfigs = [
{
job_name = "netdata";
metrics_path = "/api/v1/allmetrics";
params.format = [ "prometheus" ];
scrape_interval = "5s";
static_configs = [
{
2023-02-08 00:19:09 +01:00
targets = [ "localhost:19999" ];
2021-12-28 16:19:29 +01:00
labels = {
service = "netdata";
2023-02-08 00:19:09 +01:00
server = "robi";
2021-12-28 16:19:29 +01:00
};
}
];
}
{
2023-02-08 00:19:09 +01:00
job_name = "systemd";
2021-12-28 16:19:29 +01:00
static_configs = [{
2023-02-08 00:19:09 +01:00
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
2021-12-28 16:19:29 +01:00
}];
}
];
};
}