about summary refs log tree commit diff
path: root/modules/nixos/loki.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/nixos/loki.nix47
1 files changed, 35 insertions, 12 deletions
diff --git a/modules/nixos/loki.nix b/modules/nixos/loki.nix
index 49a9b19..0a92fbd 100644
--- a/modules/nixos/loki.nix
+++ b/modules/nixos/loki.nix
@@ -2,7 +2,6 @@
   config,
   lib,
   libNginx,
-  pkgs,
   ...
 }:
 with lib; let
@@ -42,21 +41,21 @@ in {
       configuration = rec {
         auth_enabled = false;
 
-        server = rec {
+        server = {
           http_listen_address = "127.0.0.1";
           http_listen_port = cfg.port;
 
           grpc_listen_address = "127.0.0.1";
-          grpc_listen_port = http_listen_port + 1;
+          grpc_listen_port = server.http_listen_port + 1;
 
           log_level = "warn";
         };
 
-        common = rec {
-          path_prefix = "/var/lib/loki";
+        common = {
+          path_prefix = config.services.loki.dataDir;
           storage.filesystem = {
-            chunks_directory = "${path_prefix}/chunks";
-            rules_directory = "${path_prefix}/rules";
+            chunks_directory = "${common.path_prefix}/chunks";
+            rules_directory = "${common.path_prefix}/rules";
           };
           replication_factor = 1;
           instance_interface_names = ["lo"];
@@ -66,20 +65,30 @@ in {
           };
         };
 
+        compactor = {
+          working_directory = "${common.path_prefix}/compactor";
+          retention_enabled = true;
+          retention_delete_delay = "1h";
+          retention_delete_worker_count = 64;
+        };
+
         ruler = {
-          rule_path = "${common.path_prefix}/ruler";
+          enable_api = true;
           storage = {
             type = "local";
-            local.directory =
-              pkgs.writeTextDir "ruler/ruler.yml"
-              (generators.toJSON {} {groups = [{name = "default";}];});
+            local.directory = common.storage.filesystem.rules_directory;
           };
         };
 
         limits_config = {
           max_streams_per_user = 0;
           max_global_streams_per_user = 0;
-          max_query_series = 100000; # Is this safe?
+          max_query_series = 4096;
+          retention_period = "720h";
+        };
+
+        cache_config = {
+          enable_fifocache = false;
         };
 
         schema_config.configs = [
@@ -97,6 +106,20 @@ in {
               period = "24h";
             };
           }
+          {
+            from = "2023-12-01";
+            store = "tsdb";
+            object_store = "filesystem";
+            schema = "v12";
+            index = {
+              prefix = "index_";
+              period = "24h";
+            };
+            chunks = {
+              prefix = "chunks_";
+              period = "24h";
+            };
+          }
         ];
 
         analytics.reporting_enabled = false;

Consider giving Nix/NixOS a try! <3