From c83ddbaadbf187a7f88fca23219dc72d799df634 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 12:02:23 +0200
Subject: [PATCH 1/7] Update loki-stack chart to 2.4.1

Fixes: #780
---
 ansible/roles/apps/templates/settings/loki-stack.yaml | 3 +++
 flux/oas/loki-stack_hr.yaml                           | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index c1df9b34f..2fef13cb5 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -1,5 +1,7 @@
 ---
+# https://github.com/grafana/helm-charts/blob/main/charts/loki-stack/values.yaml
 loki:
+  # https://github.com/grafana/helm-charts/blob/main/charts/loki/values.yaml
   enabled: true
   resources:
     limits:
@@ -10,6 +12,7 @@ loki:
       memory: 90Mi
 
 promtail:
+  # https://github.com/grafana/helm-charts/blob/main/charts/promtail/values.yaml
   enabled: true
   initContainer:
     enabled: true
diff --git a/flux/oas/loki-stack_hr.yaml b/flux/oas/loki-stack_hr.yaml
index 66b0aa80e..481921694 100644
--- a/flux/oas/loki-stack_hr.yaml
+++ b/flux/oas/loki-stack_hr.yaml
@@ -9,9 +9,10 @@ metadata:
 spec:
   releaseName: loki-stack
   chart:
+    # https://github.com/grafana/helm-charts/tree/main/charts/loki-stack
     repository: https://grafana.github.io/helm-charts
     name: loki-stack
-    version: 2.3.1
+    version: 2.4.1
   valuesFrom:
   - secretKeyRef:
       name: loki-stack-settings
-- 
GitLab


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 2/7] 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


From 690f87fcdc138fcc391b5377cb8c9332ad10ddd8 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 12:52:06 +0200
Subject: [PATCH 3/7] Add loki persistence

---
 ansible/roles/apps/templates/settings/loki-stack.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index eb907bb99..4316b526c 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -10,6 +10,13 @@ loki:
     requests:
       cpu: 200m
       memory: 90Mi
+  persistence:
+    enabled: true
+    accessModes:
+    - ReadWriteOnce
+    size: 10Gi
+    annotations: {}
+    # existingClaim:
   config:
     # https://github.com/grafana/loki/blob/main/cmd/loki/loki-local-config.yaml
     # https://grafana.com/docs/loki/latest/operations/storage/retention
-- 
GitLab


From 1717c31ab81f43c3a95422280529d264f16c4107 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 14:34:32 +0200
Subject: [PATCH 4/7] Reduce boltdb index period to 24h

168h produced the following error:

    invalid schema config: boltdb-shipper works best with 24h periodic index config.
    Either add a new config with future date set to 24h to retain the existing index or
    change the existing config to use 24h period.
---
 ansible/roles/apps/templates/settings/loki-stack.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index 4316b526c..f603e8cbd 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -28,7 +28,7 @@ loki:
         schema: v11
         index:
           prefix: index_
-          period: 168h  # 7 days
+          period: 24h
     storage_config:
       boltdb_shipper:
         active_index_directory: /tmp/loki/boltdb-shipper-active
-- 
GitLab


From b20f3e676cb599a58fce5d96d96fa4a4d647d3cc Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 14:50:58 +0200
Subject: [PATCH 5/7] Remove docker version info from oas-version-info.sh

---
 ansible/roles/configure/files/oas-version-info.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ansible/roles/configure/files/oas-version-info.sh b/ansible/roles/configure/files/oas-version-info.sh
index 2a2c24e83..2203959e0 100755
--- a/ansible/roles/configure/files/oas-version-info.sh
+++ b/ansible/roles/configure/files/oas-version-info.sh
@@ -3,7 +3,7 @@
 cat /var/lib/OpenAppStack/version.txt
 kubectl version
 kubectl krew version
-docker version | grep -B2 Version
+kubectl krew list
 helm version
 helm plugin list
 k3s --version
-- 
GitLab


From b199fa4c42f8b4272711625ff7482666e5724814 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 14:51:40 +0200
Subject: [PATCH 6/7] Use /data instead of /tmp for loki storage

---
 ansible/roles/apps/templates/settings/loki-stack.yaml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index f603e8cbd..5877b6fb6 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -31,14 +31,14 @@ loki:
           period: 24h
     storage_config:
       boltdb_shipper:
-        active_index_directory: /tmp/loki/boltdb-shipper-active
-        cache_location: /tmp/loki/boltdb-shipper-cache
+        active_index_directory: /data/loki/boltdb-shipper-active
+        cache_location: /data/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
+        directory: /data/loki/chunks
     compactor:
-      working_directory: /tmp/loki/boltdb-shipper-compactor
+      working_directory: /data/loki/boltdb-shipper-compactor
       shared_store: filesystem
     limits_config:
       reject_old_samples: true
-- 
GitLab


From f248d3352b6cc1eeeb5f0a9c95aa29eb66e4bd76 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 16:58:36 +0200
Subject: [PATCH 7/7] Use today as loki storage start day

---
 ansible/roles/apps/templates/settings/loki-stack.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index 5877b6fb6..1c6b32664 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -22,7 +22,7 @@ loki:
     # https://grafana.com/docs/loki/latest/operations/storage/retention
     schema_config:
       configs:
-      - from: 2020-10-24
+      - from: 2021-05-31
         store: boltdb-shipper
         object_store: filesystem
         schema: v11
-- 
GitLab