From 9abe7cbe06918b7956987aa18942e8f18a9bce3f Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 12:38:28 +0200
Subject: [PATCH] Increase loki retention time

Closes: #790
---
 .../apps/templates/settings/loki-stack.yaml   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index 2fef13cb5..eb907bb99 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -10,6 +10,37 @@ loki:
     requests:
       cpu: 200m
       memory: 90Mi
+  config:
+    # https://github.com/grafana/loki/blob/main/cmd/loki/loki-local-config.yaml
+    # https://grafana.com/docs/loki/latest/operations/storage/retention
+    schema_config:
+      configs:
+      - from: 2020-10-24
+        store: boltdb-shipper
+        object_store: filesystem
+        schema: v11
+        index:
+          prefix: index_
+          period: 168h  # 7 days
+    storage_config:
+      boltdb_shipper:
+        active_index_directory: /tmp/loki/boltdb-shipper-active
+        cache_location: /tmp/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: /tmp/loki/chunks
+    compactor:
+      working_directory: /tmp/loki/boltdb-shipper-compactor
+      shared_store: filesystem
+    limits_config:
+      reject_old_samples: true
+      reject_old_samples_max_age: 168h  # 7 days
+    chunk_store_config:
+      max_look_back_period: 672h # 28 days
+    table_manager:
+      retention_deletes_enabled: true
+      retention_period: 672h  # 28 days
 
 promtail:
   # https://github.com/grafana/helm-charts/blob/main/charts/promtail/values.yaml
-- 
GitLab