From 7d701506cef03cb306600202b413bce22bc2c0bb Mon Sep 17 00:00:00 2001 From: kat witch Date: Tue, 4 May 2021 14:38:09 +0100 Subject: [PATCH] services/netdata: Added to prometheus stack --- hosts/athame/nixos/default.nix | 1 + hosts/samhain/nixos/default.nix | 1 + hosts/yule/nixos/default.nix | 2 ++ services/netdata.nix | 24 ++++++++++++++++++++++++ services/prometheus.nix | 21 ++++++++++++++++++++- 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 services/netdata.nix diff --git a/hosts/athame/nixos/default.nix b/hosts/athame/nixos/default.nix index b69bd391..68b59b4f 100644 --- a/hosts/athame/nixos/default.nix +++ b/hosts/athame/nixos/default.nix @@ -29,6 +29,7 @@ with lib; ../../../services/loki.nix ../../../services/node-exporter.nix ../../../services/promtail.nix + ../../../services/netdata.nix ]; boot.loader.grub.enable = true; diff --git a/hosts/samhain/nixos/default.nix b/hosts/samhain/nixos/default.nix index 031532e8..4da89544 100644 --- a/hosts/samhain/nixos/default.nix +++ b/hosts/samhain/nixos/default.nix @@ -17,6 +17,7 @@ in { ../../../services/nginx.nix ../../../services/node-exporter.nix ../../../services/promtail.nix + ../../../services/netdata.nix ./thermal ./transmission.nix ./jellyfin.nix diff --git a/hosts/yule/nixos/default.nix b/hosts/yule/nixos/default.nix index 8f999265..c50ce63c 100644 --- a/hosts/yule/nixos/default.nix +++ b/hosts/yule/nixos/default.nix @@ -9,6 +9,8 @@ with lib; ../../../services/restic.nix ../../../services/node-exporter.nix ../../../services/promtail.nix + ../../../services/netdata.nix + ../../../services/nginx.nix profiles.gui profiles.sway profiles.kat diff --git a/services/netdata.nix b/services/netdata.nix new file mode 100644 index 00000000..53b67a2b --- /dev/null +++ b/services/netdata.nix @@ -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/"; + }; + }; + }; + }; +}; +} diff --git a/services/prometheus.nix b/services/prometheus.nix index c8eb07a7..c789a844 100644 --- a/services/prometheus.nix +++ b/services/prometheus.nix @@ -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; };