From 0ec97d1e7dc153634cabb0ba2cf7ab9a2b0e6df1 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 30 May 2021 19:08:51 +0200 Subject: monitoringServer: init --- usecases/server/monitoring-server.nix | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 usecases/server/monitoring-server.nix (limited to 'usecases/server/monitoring-server.nix') diff --git a/usecases/server/monitoring-server.nix b/usecases/server/monitoring-server.nix new file mode 100644 index 0000000..823f4f9 --- /dev/null +++ b/usecases/server/monitoring-server.nix @@ -0,0 +1,55 @@ +inputs: + +{ config, ... }: + +{ + imports = [ + (import ./monitoring-target.nix inputs) + ]; + + services.prometheus = { + enable = true; + + listenAddress = "127.0.0.1"; + + # TODO: for NixOS 21.05 + extraFlags = [ "--storage.tsdb.retention=15w" ]; + #retentionTime = "15w"; + + scrapeConfigs = [ + { + job_name = "prometheus"; + static_configs = [ + { targets = [ "localhost:${toString config.services.prometheus.port}" ]; } + ]; + } + + { + job_name = "node_exporter"; + static_configs = [ + { targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; } + ]; + } + + { + job_name = "grafana"; + static_configs = [ + { targets = [ "localhost:${toString config.services.grafana.port}" ]; } + ]; + } + ]; + }; + + services.grafana = { + enable = true; + + addr = config.topology.mainVpn.currentNodeIP; + port = 3001; + + analytics.reporting.enable = false; + }; + + networking.firewall.interfaces.${config.topology.mainVpn.interfaceName}.allowedTCPPorts = [ + config.services.grafana.port + ]; +} -- cgit v1.2.3