nixos-config/legacy/robi/prometheus.nix

71 lines
1.6 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}" ];
2023-02-24 02:12:12 +01:00
labels = {
service = "node-exporter";
2023-02-24 03:51:12 +01:00
server = "robi";
};
}];
}
{
# see https://www.home-assistant.io/integrations/prometheus/
job_name = "telgraf";
metrics_path = "/metrics";
static_configs = [{
targets = [ "localhost:9273" ];
labels = {
service = "telegraf";
server = "robi";
2023-02-24 02:12:12 +01:00
};
2021-12-28 16:19:29 +01:00
}];
}
];
};
}