From a4592ffda397e7c7afd1a21439b16caadfbefe01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 1 Dec 2024 20:51:14 +0100 Subject: [PATCH] Improve monitoring stuff --- services/monitoring/default.nix | 1 + services/monitoring/prometheus.nix | 22 ++++++++++++++++++++ system/monitoring/logs.nix | 2 ++ system/monitoring/metrics.nix | 33 +++++------------------------- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/services/monitoring/default.nix b/services/monitoring/default.nix index 370dba5..93527a0 100644 --- a/services/monitoring/default.nix +++ b/services/monitoring/default.nix @@ -3,5 +3,6 @@ imports = [ ./loki.nix ./grafana.nix + ./prometheus.nix ]; } diff --git a/services/monitoring/prometheus.nix b/services/monitoring/prometheus.nix index 5c0d6a5..ec86838 100644 --- a/services/monitoring/prometheus.nix +++ b/services/monitoring/prometheus.nix @@ -2,5 +2,27 @@ { services.prometheus = { enable = true; + alertmanager = { + enable = true; + }; + scrapeConfigs = [ + { + job_name = "node-exporter"; + static_configs = [ + { + targets = [ + # Node exporter + "gunter.home.2rjus.net:9100" + "ca.home.2rjus.net:9100" + "monitoring01.home.2rjus.net:9100" + "ns1.home.2rjus.net:9100" + "ns2.home.2rjus.net:9100" + "http-proxy.home.2rjus.net:9100" + "ha1.home.2rjus.net:9100" + ]; + } + ]; + } + ]; }; } diff --git a/system/monitoring/logs.nix b/system/monitoring/logs.nix index a3376c7..e003f97 100644 --- a/system/monitoring/logs.nix +++ b/system/monitoring/logs.nix @@ -6,6 +6,8 @@ server = { http_listen_address = "0.0.0.0"; http_listen_port = 9099; + grpc_listen_address = "0.0.0.0"; + grpc_listen_port = 9098; }; clients = [ diff --git a/system/monitoring/metrics.nix b/system/monitoring/metrics.nix index 56adbfd..61f8d91 100644 --- a/system/monitoring/metrics.nix +++ b/system/monitoring/metrics.nix @@ -1,33 +1,10 @@ { pkgs, ... }: { - environment.systemPackages = with pkgs; [ - prometheus-node-exporter - prometheus-systemd-exporter - ]; - - systemd.services."node-exporter" = { + services.prometheus.exporters.node = { enable = true; - unitConfig = { - Description = "Prometheus Node Exporter"; - After = [ "network.target" ]; - }; - serviceConfig = { - ExecStart = "${pkgs.prometheus-node-exporter}/bin/node_exporter"; - }; - wantedBy = [ "multi-user.target" ]; + enabledCollectors = [ + "systemd" + "logind" + ]; }; - - systemd.services."systemd-exporter" = { - enable = true; - unitConfig = { - Description = "Prometheus Systemd Exporter"; - After = [ "network.target" ]; - }; - serviceConfig = { - ExecStart = "${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter"; - }; - wantedBy = [ "multi-user.target" ]; - }; - - networking.firewall.allowedTCPPorts = [ 9100 9558 ]; }