From 9dd6584bee1b7264ba8e9601c14afecabf7033f0 Mon Sep 17 00:00:00 2001 From: Michel Hollands Date: Mon, 24 Jul 2023 13:42:55 +0100 Subject: [PATCH] Add full object with stage replace block Signed-off-by: Michel Hollands --- .../templates/agent/_helpers-agent.tpl | 2 +- charts/meta-monitoring/templates/agent/config.yaml | 9 +++++---- charts/meta-monitoring/values.yaml | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/charts/meta-monitoring/templates/agent/_helpers-agent.tpl b/charts/meta-monitoring/templates/agent/_helpers-agent.tpl index 906217b..5994c4e 100644 --- a/charts/meta-monitoring/templates/agent/_helpers-agent.tpl +++ b/charts/meta-monitoring/templates/agent/_helpers-agent.tpl @@ -18,7 +18,7 @@ {{- end }} {{- define "agent.loki_process_targets" -}} -{{- if empty .Values.logs.piiregexes }} +{{- if empty .Values.logs.piiRegexes }} {{- include "agent.loki_write_targets" . }} {{- else }} {{- printf "loki.process.PII.receiver" }} diff --git a/charts/meta-monitoring/templates/agent/config.yaml b/charts/meta-monitoring/templates/agent/config.yaml index b9e9313..34a663d 100644 --- a/charts/meta-monitoring/templates/agent/config.yaml +++ b/charts/meta-monitoring/templates/agent/config.yaml @@ -43,14 +43,15 @@ data: forward_to = [ {{ include "agent.loki_process_targets" . }} ] } - {{- if not (empty .Values.logs.piiregexes) }} + {{- if not (empty .Values.logs.piiRegexes) }} loki.process "PII" { forward_to = [ {{ include "agent.loki_write_targets" . }} ] - {{- range .Values.logs.piiregexes }} + {{- range .Values.logs.piiRegexes }} stage.replace { - expression = "{{ . }}" - replace = "*****" + expression = "{{ .expression }}" + source = "{{ .source }}" + replace = "{{ .replace }}" } {{- end }} } diff --git a/charts/meta-monitoring/values.yaml b/charts/meta-monitoring/values.yaml index 6289867..25f48e9 100644 --- a/charts/meta-monitoring/values.yaml +++ b/charts/meta-monitoring/values.yaml @@ -32,14 +32,14 @@ cloud: username: password: -# Adding regexes here will add a stage.replace block that parses the log lines using a regular expression -# and replaces the capture group in the regex with "*****". -# For example the regex "password (\\S+)" will replace the line -# we should not be logging the password xyzabc at all -# with: -# we should not be logging the password ***** at all +# Adding regexes here will add a stage.replace block. For more information see +# https://grafana.com/docs/agent/latest/flow/reference/components/loki.process/#stagereplace-block logs: - piiregexes: + piiRegexes: + # This example replaces the word after password with ***** + # - expression: "password (\\\\S+)" + # source: "" # Empty uses the log message + # replace: "*****"" global: minio: