From cd822b8f21420096bada2a6744208a66d5d3f956 Mon Sep 17 00:00:00 2001 From: Ahwx Date: Tue, 16 Jun 2026 19:02:09 +0200 Subject: [PATCH] feat: improve monitoring by adding more modules for prometheus; adds loki --- modules/services/monitoring.nix | 90 ++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/modules/services/monitoring.nix b/modules/services/monitoring.nix index b24e67b..0c8b7d6 100644 --- a/modules/services/monitoring.nix +++ b/modules/services/monitoring.nix @@ -5,9 +5,30 @@ enable = true; port = 9001; exporters = { + smartctl.enable = true; + zfs.enable = true; node = { enable = true; - enabledCollectors = [ "systemd" ]; + enabledCollectors = [ + "systemd" + "cpu" + "cpufreq" + "diskstats" + "filesystem" + "loadavg" + "meminfo" + "netdev" + "stat" + "time" + "uname" + "hwmon" + "bcache" + "conntrack" + "dmi" + "nvme" + "thermal_zone" + "zfs" + ]; port = 9002; }; smokeping = { @@ -37,12 +58,69 @@ } ]; } + { + job_name = "${host} - smartctl"; + static_configs = [ + { + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}" ]; + } + ]; + } + { + job_name = "${host} - zfs"; + static_configs = [ + { + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.zfs.port}" ]; + } + ]; + } ]; }; + loki = { + enable = true; + configuration = { + auth_enabled = false; + server.http_listen_port = 9003; + + common = { + path_prefix = "/var/lib/loki"; + replication_factor = 1; + ring.kvstore.store = "inmemory"; + }; + + schema_config.configs = [ + { + from = "2024-01-01"; + store = "tsdb"; + object_store = "filesystem"; + schema = "v13"; + index = { + prefix = "index_"; + period = "24h"; + }; + } + ]; + + storage_config.filesystem.directory = "/var/lib/loki/chunks"; + + limits_config = { + retention_period = "90d"; + reject_old_samples = true; + reject_old_samples_max_age = "8h"; + }; + + compactor = { + working_directory = "/var/lib/loki/compactor"; + delete_request_store = "filesystem"; + retention_enabled = true; + }; + }; + }; + }; + networking.firewall = { + allowedTCPPorts = [ + 9001 + 9003 + ]; }; - # networking.firewall = { - # allowedTCPPorts = [ - # 9001 - # ]; - # }; }