diff --git a/nixos/modules/monitoring/exporters/promtail.nix b/nixos/modules/monitoring/exporters/promtail.nix index d0a49971dda80c64e0c9f190f671c0a756c21b73..def02568e693be99cb1fe94c3e3d15fc81df5c1b 100644 --- a/nixos/modules/monitoring/exporters/promtail.nix +++ b/nixos/modules/monitoring/exporters/promtail.nix @@ -11,6 +11,7 @@ let cfg = config.services.private-storage.monitoring.exporters.promtail; hostName = config.networking.hostName; + logRetention = toString(config.services.private-storage.monitoring.policy.logRetentionSeconds) + "s"; in { options.services.private-storage.monitoring.exporters.promtail = { @@ -40,7 +41,7 @@ in { services.journald.extraConfig = '' # This tells journald it can discard log files that contain only log # entries that are older than 29 days. - MaxRetentionSec=29day + MaxRetentionSec=${logRetention} # This tells journald to start a new log file once a day. Together with # the MaxRetentionSec setting, this means that entries are kept for diff --git a/nixos/modules/monitoring/server/loki.nix b/nixos/modules/monitoring/server/loki.nix index 491d1a4c5edd1100ea17c26bbe8e8799b9424582..f73720a5761ebdcbf3c47db9291ac76eb22ca1de 100644 --- a/nixos/modules/monitoring/server/loki.nix +++ b/nixos/modules/monitoring/server/loki.nix @@ -7,7 +7,11 @@ # https://grafana.com/docs/loki/latest/configuration/examples/#complete-local-configyaml # -{ +{ config, ...}: +let + logRetention = toString(config.services.private-storage.monitoring.policy.logRetentionSeconds) + "s"; + +in { config.networking.firewall.interfaces.monitoringvpn.allowedTCPPorts = [ 3100 ]; config.services.loki = { @@ -61,7 +65,7 @@ table_manager = { retention_deletes_enabled = true; - retention_period = "336h"; # two weeks + retention_period = logRetention; }; }; };