diff options
Diffstat (limited to 'modules/loki.nix')
-rw-r--r-- | modules/loki.nix | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/modules/loki.nix b/modules/loki.nix index a9ebb28..44e663f 100644 --- a/modules/loki.nix +++ b/modules/loki.nix @@ -32,7 +32,12 @@ in enable = true; upstreams.loki.servers."127.0.0.1:${toString cfg.port}" = { }; virtualHosts.${cfg.domain} = { - locations."/".proxyPass = "http://loki"; + locations = { + "/".proxyPass = "http://loki"; + # "/loki".extraConfig = '' + # rewrite ^/loki/(.*)$ /$1 break; + # ''; + }; extraConfig = libNginx.config.internalOnly; }; }; @@ -47,10 +52,12 @@ in http_listen_address = "127.0.0.1"; http_listen_port = cfg.port; - grpc_listen_address = "127.0.0.1"; + grpc_listen_address = "0.0.0.0"; grpc_listen_port = server.http_listen_port + 1; + log_format = "logfmt"; log_level = "warn"; + log_source_ips_enabled = true; }; common = { @@ -62,13 +69,13 @@ in replication_factor = 1; ring = { instance_addr = "127.0.0.1"; - kvstore.store = "inmemory"; + kvstore.store = "memberlist"; }; }; - ingester = { - chunk_idle_period = "15m"; - max_chunk_age = "15m"; + memberlist = { + bind_port = 7946; + message_history_buffer_bytes = lib.pow 2 13; }; compactor = { @@ -76,6 +83,7 @@ in retention_enabled = true; retention_delete_delay = "1h"; retention_delete_worker_count = 64; + delete_request_store = "filesystem"; }; ruler = { @@ -90,24 +98,20 @@ in max_streams_per_user = 0; max_global_streams_per_user = 0; max_query_series = 4096; - retention_period = "720h"; + retention_period = "14d"; deletion_mode = "filter-and-delete"; }; schema_config.configs = [ { - from = "2024-01-01"; - store = "tsdb"; + from = "2025-01-01"; object_store = "filesystem"; - schema = "v12"; + store = "tsdb"; + schema = "v13"; index = { prefix = "index_"; period = "24h"; }; - chunks = { - prefix = "chunks_"; - period = "24h"; - }; } ]; @@ -115,11 +119,19 @@ in }; }; - systemd.tmpfiles.rules = with config.services.loki.configuration.common; [ - "d ${path_prefix} 0700 loki loki - -" - "d ${storage.filesystem.chunks_directory} 0700 loki loki - -" - "d ${storage.filesystem.rules_directory} 0700 loki loki - -" - ]; + environment.etc."alloy/loki.alloy".text = '' + prometheus.scrape "loki" { + targets = [ + { + __address__ = "127.0.0.1:${toString cfg.port}", + instance = "${config.networking.hostName}", + }, + ] + forward_to = [prometheus.relabel.default.receiver] + } + ''; + + systemd.services.alloy.reloadTriggers = [ config.environment.etc."alloy/loki.alloy".source ]; topology.nodes.${this.hostname}.services.loki.info = cfg.domain; }; |