Add way to gather extra metrics and logs

Signed-off-by: Michel Hollands <michel.hollands@gmail.com>
This commit is contained in:
Michel Hollands 2024-05-02 17:14:09 +01:00
parent 2906836eae
commit e7ad1383a6
3 changed files with 31 additions and 5 deletions

View File

@ -54,4 +54,26 @@
{{- $list = append $list ("otelcol.exporter.otlphttp.cloud.input") }} {{- $list = append $list ("otelcol.exporter.otlphttp.cloud.input") }}
{{- end }} {{- end }}
{{- join ", " $list }} {{- join ", " $list }}
{{- end }}
{{- define "agent.all_logs" -}}
{{- $list := list }}
{{- range .Values.logs.retain }}
{{- $list = append $list . }}
{{- end }}
{{- range .Values.logs.extraLogs }}
{{- $list = append $list . }}
{{- end }}
{{- join "|" $list }}
{{- end }}
{{- define "agent.all_metrics" -}}
{{- $list := list }}
{{- range .Values.metrics.retain }}
{{- $list = append $list . }}
{{- end }}
{{- range .Values.metrics.extraMetrics }}
{{- $list = append $list . }}
{{- end }}
{{- join "|" $list }}
{{- end }} {{- end }}

View File

@ -59,9 +59,9 @@ data:
loki.process "filter" { loki.process "filter" {
forward_to = [ {{ include "agent.loki_write_targets" . }} ] forward_to = [ {{ include "agent.loki_write_targets" . }} ]
{{- if not (empty .Values.logs.retain) }} {{- if or (not (empty .Values.logs.retain)) (not (empty .Values.logs.extraLogs)) }}
stage.match { stage.match {
selector = "{cluster=\"{{- .Values.clusterLabelValue -}}\", namespace=~\"{{- join "|" .Values.namespacesToMonitor -}}|{{- $.Release.Namespace -}}\", pod=~\"loki.*\"} !~ \"{{ join "|" .Values.logs.retain }}\"" selector = "{cluster=\"{{- .Values.clusterLabelValue -}}\", namespace=~\"{{- join "|" .Values.namespacesToMonitor -}}|{{- $.Release.Namespace -}}\", pod=~\"loki.*\"} !~ \"{{ include "agent.all_logs" . }}\""
action = "drop" action = "drop"
} }
{{- end }} {{- end }}
@ -137,7 +137,7 @@ data:
prometheus.relabel "filter" { prometheus.relabel "filter" {
rule { rule {
source_labels = ["__name__"] source_labels = ["__name__"]
regex = "({{ join "|" .Values.metrics.retain }})" regex = "({{ include "agent.all_metrics" . }})"
action = "keep" action = "keep"
} }

View File

@ -70,12 +70,14 @@ logs:
- caller=metrics.go - caller=metrics.go
# This shows any errors # This shows any errors
- level=error - level=error
# This shows the ingest requests and is very noisy. Uncomment to include.
# - caller=push.go
# Log lines for delete requests # Log lines for delete requests
- delete request for user added - delete request for user added
- Started processing delete request - Started processing delete request
- delete request for user marked as processed - delete request for user marked as processed
# This shows the ingest requests and is very noisy. Uncomment to include.
# - caller=push.go
# Additional log lines to retain
extraLogs: []
metrics: metrics:
# The list of metrics to retain for logging dashboards # The list of metrics to retain for logging dashboards
@ -175,6 +177,8 @@ metrics:
- node_disk_read_bytes_total - node_disk_read_bytes_total
- node_disk_written_bytes_total - node_disk_written_bytes_total
- promtail_custom_bad_words_total - promtail_custom_bad_words_total
# Additional metrics to retain
extraMetrics: []
# 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: