Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out log lines not matching list #22

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/meta-monitoring/templates/agent/_helpers-agent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{{- end }}

{{- define "agent.loki_process_targets" -}}
{{- if empty .Values.logs.piiRegexes }}
{{- if and (empty .Values.logs.piiRegexes) (empty .Values.logs.retain) }}
{{- include "agent.loki_write_targets" . }}
{{- else }}
{{- printf "loki.process.PII.receiver" }}
{{- printf "loki.process.filter.receiver" }}
DylanGuedes marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- end }}

Expand Down
13 changes: 11 additions & 2 deletions charts/meta-monitoring/templates/agent/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,26 @@ data:
forward_to = [ {{ include "agent.loki_process_targets" . }} ]
}

{{- if not (empty .Values.logs.piiRegexes) }}
loki.process "PII" {
{{- if or (not (empty .Values.logs.retain)) (not (empty .Values.logs.piiRegexes)) }}
loki.process "filter" {
forward_to = [ {{ include "agent.loki_write_targets" . }} ]

{{- if not (empty .Values.logs.retain) }}
stage.match {
selector = "{cluster=\"{{- .Values.clusterName -}}\"} !~ \"{{ join "|" .Values.logs.retain }}\""
action = "drop"
}
{{- end }}

{{- if not (empty .Values.logs.piiRegexes) }}
{{- range .Values.logs.piiRegexes }}
stage.replace {
expression = "{{ .expression }}"
source = "{{ .source }}"
replace = "{{ .replace }}"
}
{{- end }}
{{- end }}
}
{{- end }}
{{- end }}
Expand Down
13 changes: 11 additions & 2 deletions charts/meta-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,24 @@ local:
minio:
enabled: false # This should be set to true if any of the previous is enabled

# Adding regexes here will add a stage.replace block for logs. For more information see
# https://grafana.com/docs/agent/latest/flow/reference/components/loki.process/#stagereplace-block
logs:
# Adding regexes here will add a stage.replace block for logs. For more information see
# https://grafana.com/docs/agent/latest/flow/reference/components/loki.process/#stagereplace-block
piiRegexes:
# This example replaces the word after password with *****
# - expression: "password (\\\\S+)"
# source: "" # Empty uses the log message
# replace: "*****""

# The lines matching these will be kept in Loki
retain:
# This shows the queries
- caller=metrics.go
# This shows any errors
- level=error
# This shows the ingest requests and is very noisy. Uncomment to include.
# - caller=push.go

# Set enabled = true to add the default logs/metrics/traces dashboards to the local Grafana
dashboards:
logs:
Expand Down
Loading