From a7fe5b26681a6e11e0a0afab4ddf10f03bd88fe7 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Mon, 31 May 2021 16:30:47 +0200
Subject: [PATCH] Add proper labels to eventrouter logs

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

diff --git a/ansible/roles/apps/templates/settings/loki-stack.yaml b/ansible/roles/apps/templates/settings/loki-stack.yaml
index 1c6b32664..2d5bba2a6 100644
--- a/ansible/roles/apps/templates/settings/loki-stack.yaml
+++ b/ansible/roles/apps/templates/settings/loki-stack.yaml
@@ -62,3 +62,29 @@ promtail:
     requests:
       cpu: 300m
       memory: 128Mi
+  config:
+    # https://github.com/grafana/helm-charts/blob/main/charts/promtail/values.yaml#L217
+    snippets:
+      # https://grafana.com/docs/loki/latest/clients/promtail/pipelines/
+      pipelineStages:
+        - cri: {}
+        - match:
+            selector: '{app="eventrouter"}'
+            stages:
+              - json:
+                  expressions:
+                    event_verb: verb
+                    event_kind: event.involvedObject.kind
+                    event_reason: event.reason
+                    event_namespace: event.involvedObject.namespace
+                    event_name: event.metadata.name
+                    event_source_host: event.source.host
+                    event_source_component: event.source.component
+              - labels:
+                  event_verb:
+                  event_kind:
+                  event_reason:
+                  event_namespace:
+                  event_name:
+                  event_source_host:
+                  event_source_component:
-- 
GitLab