From 8cc4407ad65c7e6ae7b00da4e9363cd17564b016 Mon Sep 17 00:00:00 2001
From: Kristian Klausen <kristian@klausen.dk>
Date: Sat, 6 Nov 2021 18:37:40 +0100
Subject: [PATCH] loki: Simplify loki.yaml

Loki v2.4.0 introduced a common config section[1][2] making the config
much smaller and better defaults.

So stripped loki.yaml down, removed options where the default is "good
enough" and tweaked retention settings per the upgrade notes[3].

So the config should basically be the example loki.yaml[4] + compactor,
retention enabled and a few tweaks (ex: compress chunks with zstd).

[1] https://github.com/grafana/loki/releases/tag/v2.4.0
[2] https://grafana.com/docs/loki/latest/configuration/#common_config
[3] https://grafana.com/docs/loki/latest/upgrading/#the-single-binary-no-longer-runs-a-table-manager
[4] https://github.com/grafana/loki/blob/v2.4.0/cmd/loki/loki-local-config.yaml
---
 roles/loki/files/loki.yaml | 51 +++++++++++---------------------------
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/roles/loki/files/loki.yaml b/roles/loki/files/loki.yaml
index 48f409dc0..022ec96e4 100644
--- a/roles/loki/files/loki.yaml
+++ b/roles/loki/files/loki.yaml
@@ -1,5 +1,3 @@
-# Enables authentication through the X-Scope-OrgID header, which must be present
-# if true. If false, the OrgID will always be set to "fake".
 auth_enabled: false
 
 server:
@@ -8,24 +6,22 @@ server:
   grpc_listen_address: 127.0.0.1
   grpc_listen_port: 9095
 
+common:
+  path_prefix: /var/lib/loki
+  storage:
+    filesystem:
+      chunks_directory: /var/lib/loki/chunks
+      rules_directory: /var/lib/loki/rules
+  replication_factor: 1
+  ring:
+    instance_addr: 127.0.0.1
+    kvstore:
+      store: inmemory
+
 ingester:
   wal:
-    enabled: true
-    dir: /var/lib/loki/wal
     replay_memory_ceiling: 200MB
-  lifecycler:
-    address: 127.0.0.1
-    ring:
-      kvstore:
-        store: inmemory
-      replication_factor: 1
-    final_sleep: 0s
-  chunk_idle_period: 1h       # Any chunk not receiving new logs in this time will be flushed
-  max_chunk_age: 1h           # All chunks will be flushed when they hit this age, default is 1h
-  chunk_target_size: 1536000  # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
   chunk_encoding: zstd
-  chunk_retain_period: 30s    # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
-  max_transfer_retries: 0     # Chunk transfers disabled
 
 schema_config:
   configs:
@@ -37,27 +33,10 @@ schema_config:
         prefix: index_
         period: 24h
 
-storage_config:
-  boltdb_shipper:
-    active_index_directory: /var/lib/loki/boltdb-shipper-active
-    cache_location: /var/lib/loki/boltdb-shipper-cache
-    cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
-    shared_store: filesystem
-  filesystem:
-    directory: /var/lib/loki/chunks
-
 compactor:
-  working_directory: /var/lib/loki/boltdb-shipper-compactor
-  shared_store: filesystem
+  retention_enabled: true
 
 limits_config:
-  reject_old_samples: true
-  reject_old_samples_max_age: 168h
   max_query_series: 10000
-
-chunk_store_config:
-  max_look_back_period: 2184h
-
-table_manager:
-  retention_deletes_enabled: true
-  retention_period: 2184h  # 91 days
+  retention_period: 91d
+  max_query_lookback: 91d
-- 
GitLab