Merge pull request #22 from grafana/filter_log_lines
Filter out log lines not matching list
This commit is contained in:
commit
1bffcac5e5
@ -18,10 +18,10 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "agent.loki_process_targets" -}}
|
{{- 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" . }}
|
{{- include "agent.loki_write_targets" . }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- printf "loki.process.PII.receiver" }}
|
{{- printf "loki.process.filter.receiver" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
@ -45,10 +45,18 @@ data:
|
|||||||
forward_to = [ {{ include "agent.loki_process_targets" . }} ]
|
forward_to = [ {{ include "agent.loki_process_targets" . }} ]
|
||||||
}
|
}
|
||||||
|
|
||||||
{{- if not (empty .Values.logs.piiRegexes) }}
|
{{- if or (not (empty .Values.logs.retain)) (not (empty .Values.logs.piiRegexes)) }}
|
||||||
loki.process "PII" {
|
loki.process "filter" {
|
||||||
forward_to = [ {{ include "agent.loki_write_targets" . }} ]
|
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 }}
|
{{- range .Values.logs.piiRegexes }}
|
||||||
stage.replace {
|
stage.replace {
|
||||||
expression = "{{ .expression }}"
|
expression = "{{ .expression }}"
|
||||||
@ -56,6 +64,7 @@ data:
|
|||||||
replace = "{{ .replace }}"
|
replace = "{{ .replace }}"
|
||||||
}
|
}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
}
|
}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -35,15 +35,24 @@ local:
|
|||||||
minio:
|
minio:
|
||||||
enabled: false # This should be set to true if any of the previous is enabled
|
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:
|
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:
|
piiRegexes:
|
||||||
# This example replaces the word after password with *****
|
# This example replaces the word after password with *****
|
||||||
# - expression: "password (\\\\S+)"
|
# - expression: "password (\\\\S+)"
|
||||||
# source: "" # Empty uses the log message
|
# source: "" # Empty uses the log message
|
||||||
# replace: "*****""
|
# 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
|
# Set enabled = true to add the default logs/metrics/traces dashboards to the local Grafana
|
||||||
dashboards:
|
dashboards:
|
||||||
logs:
|
logs:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user