services/netdata: Added to prometheus stack

This commit is contained in:
kat witch 2021-05-04 14:38:09 +01:00
parent f7f116a9a8
commit 7d701506ce
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
5 changed files with 48 additions and 1 deletions

24
services/netdata.nix Normal file
View file

@ -0,0 +1,24 @@
{ config, ... }:
{
katnet.private.tcp.ports = [ 19999 ];
services.netdata = {
enable = true;
};
services.nginx = {#
enable = true;
virtualHosts = {
"${config.networking.hostName}.net.kittywit.ch" = {
useACMEHost = "${config.networking.hostName}.net.kittywit.ch";
forceSSL = true;
locations = {
"/netdata" = {
proxyPass = "http://[::1]:19999/";
};
};
};
};
};
}

View file

@ -8,6 +8,11 @@ let
(filterAttrs
(_: host: host.config.services.prometheus.exporters.node.enable)
hosts));
nd_configs =
(mapAttrs (hostName: host: host.config.services.netdata)
(filterAttrs
(_: host: host.config.services.netdata.enable)
hosts));
in {
services.prometheus = {
enable = true;
@ -17,9 +22,23 @@ in {
static_configs = [{ targets = [ "boline.net.kittywit.ch:8002" ];}];
}
] ++ mapAttrsToList (hostName: prom: {
job_name = "${hostName}-nd";
metrics_path = "/api/v1/allmetrics";
honor_labels = true;
params = {
format = [ "prometheus" ];
};
static_configs = [{
targets = [
"${hostName}.net.kittywit.ch:19999"
];
}];
}) nd_configs ++ mapAttrsToList (hostName: prom: {
job_name = hostName;
static_configs = [{
targets = [ "${hostName}.net.kittywit.ch:${toString prom.port}" ];
targets = [
"${hostName}.net.kittywit.ch:${toString prom.port}"
];
}];
}) prom_configs;
};