From ce3f72e4fa66d53cc9acfcf3cd8881998a1d6e7f Mon Sep 17 00:00:00 2001 From: Dolan Antenucci Date: Thu, 7 Nov 2024 10:43:15 -0700 Subject: [PATCH 1/3] Adding optional spanlog converting of traces to logs --- .../alloy_config/_processors.alloy.txt | 18 +++++++++++++++++- charts/k8s-monitoring-v1/values.yaml | 5 +++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt b/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt index 94b2cf444..751263d9c 100644 --- a/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt +++ b/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt @@ -360,12 +360,28 @@ otelcol.processor.filter "default" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.batch.batch_processor.input] {{- end }} -{{- if .Values.traces.enabled }} + +{{- if and .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} + traces = [otelcol.connector.spanlogs.default.input, otelcol.processor.batch.batch_processor.input] +{{- else if .Values.receivers.processors.otlp_traces_to_logs.enabled }} + traces = [otelcol.connector.spanlogs.default.input] +{{- else if .Values.traces.enabled }} traces = [otelcol.processor.batch.batch_processor.input] {{- end }} } } +{{- if .Values.receivers.processors.otlp_traces_to_logs.enabled }} +otelcol.connector.spanlogs "default" { + roots = true + spans = true + processes = true + output { + logs = [otelcol.processor.batch.batch_processor.input] + } +} +{{- end }} + otelcol.processor.batch "batch_processor" { {{- with .Values.receivers.processors.batch }} send_batch_size = {{ .size | int }} diff --git a/charts/k8s-monitoring-v1/values.yaml b/charts/k8s-monitoring-v1/values.yaml index ad85ca295..b4b4aca73 100644 --- a/charts/k8s-monitoring-v1/values.yaml +++ b/charts/k8s-monitoring-v1/values.yaml @@ -2129,6 +2129,11 @@ receivers: - os resourceAttributes: {} + # Use a spanlog to convert OTLP traces to logs + otlp_traces_to_logs: + enabled: false + + grafanaCloudMetrics: # -- Generate host info metrics from telemetry data, used in Application Observability in Grafana Cloud. # @section -- OTEL Receivers (Processors) From 250ec65dcd646ccbba7dc372768a45f71fb2275b Mon Sep 17 00:00:00 2001 From: Dolan Antenucci Date: Fri, 8 Nov 2024 08:02:42 -0700 Subject: [PATCH 2/3] Enabling receiver traces if spanlog being used downstream --- .../templates/alloy_config/_receivers_otlp.alloy.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/k8s-monitoring-v1/templates/alloy_config/_receivers_otlp.alloy.txt b/charts/k8s-monitoring-v1/templates/alloy_config/_receivers_otlp.alloy.txt index 8a5025568..937ef1a70 100644 --- a/charts/k8s-monitoring-v1/templates/alloy_config/_receivers_otlp.alloy.txt +++ b/charts/k8s-monitoring-v1/templates/alloy_config/_receivers_otlp.alloy.txt @@ -44,7 +44,7 @@ otelcol.receiver.otlp "receiver" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.resourcedetection.default.input] {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} traces = [otelcol.processor.resourcedetection.default.input] {{- end }} } From 03a1ba44ce37fb5419972abda9f89a7f4ef9d3fd Mon Sep 17 00:00:00 2001 From: Dolan Antenucci Date: Fri, 8 Nov 2024 10:45:36 -0700 Subject: [PATCH 3/3] Adding more checks for traces-to-logs flag --- .../templates/alloy_config/_processors.alloy.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt b/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt index 751263d9c..90252e56a 100644 --- a/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt +++ b/charts/k8s-monitoring-v1/templates/alloy_config/_processors.alloy.txt @@ -47,7 +47,7 @@ otelcol.processor.resourcedetection "default" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.k8sattributes.default.input] {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} traces = [otelcol.processor.k8sattributes.default.input] {{- end }} } @@ -86,7 +86,7 @@ otelcol.processor.k8sattributes "default" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.attributes.default.input] {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} traces = [otelcol.processor.attributes.default.input] {{- end }} } @@ -155,10 +155,10 @@ otelcol.processor.attributes "default" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.transform.default.input] {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} traces = [ otelcol.processor.transform.default.input, - {{- if and .Values.metrics.enabled .Values.receivers.grafanaCloudMetrics.enabled }} + {{- if and .Values.metrics.enabled .Values.traces.enabled .Values.receivers.grafanaCloudMetrics.enabled }} otelcol.connector.host_info.default.input, {{- end }} ] @@ -257,7 +257,7 @@ otelcol.processor.transform "default" { } {{- end }} {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} trace_statements { context = "resource" statements = [ @@ -298,7 +298,7 @@ otelcol.processor.transform "default" { {{- if .Values.logs.enabled }} logs = [otelcol.processor.filter.default.input] {{- end }} -{{- if .Values.traces.enabled }} +{{- if or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled }} traces = [otelcol.processor.filter.default.input] {{- end }} } @@ -334,7 +334,7 @@ otelcol.processor.filter "default" { ] } {{- end }} -{{- if and .Values.traces.enabled (or .Values.traces.receiver.filters.span .Values.traces.receiver.filters.spanevent) }} +{{- if and (or .Values.traces.enabled .Values.receivers.processors.otlp_traces_to_logs.enabled) (or .Values.traces.receiver.filters.span .Values.traces.receiver.filters.spanevent) }} traces { {{- if .Values.traces.receiver.filters.span }} span = [