summaryrefslogtreecommitdiff
path: root/os/srv/loki.nix
blob: 84b94d834c5e248c1897b18620f6dcc0ac3ab6f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ config, lib, ... }:
let
  cfg = config.os.srv.loki;
in
{
  options.os.srv.loki.enable = lib.mkEnableOption "enables loki";
  config = lib.mkIf cfg.enable {
    services.loki = {
      enable = true;
      configuration = {
        server = {
          http_listen_address = "0.0.0.0";
          http_compress_responses = true;
        };

        common = {
          instance_addr = "127.0.0.1";
          path_prefix = "/var/lib/loki";
          replication_factor = 1;

          storage.filesystem = {
            chunks_directory = "/var/lib/loki/chunks";
            rules_directory = "/var/lib/loki/rules";
          };
        };

        schema_config.configs = [
          {
            from = "2026-01-01";
            store = "tsdb";
            object_store = "filesystem";
            schema = "v13";
            index = {
              prefix = "loki_index_";
              period = "24h";
            };
          }
        ];

        ingester.wal.enabled = true;

        limits_config = {
          max_entries_limit_per_query = 10000;
          reject_old_samples_max_age = "720h";
          retention_period = "90d";
          volume_enabled = true;
        };

        compactor = {
          enabled = true;
          retention_enabled = true;
          retention_delete_delay = "1h";
          compactor_window = "168h";
        };

        querier.query_timeout = "5m";
        query_range.out_of_order_time_shifting = "5m";
        analytics.reporting_enabled = false;
      };
    };
  };
}