Skip to content

Commit daab50e

Browse files
authored
Support pushing span/trace through to splunk HEC (signalfx#629)
I wanted to export spans to our splunk setup from the gateway but the way the chart is currently set up made it difficult to get all the pieces to match up (particularly port declarations across deployment/service/pods) without manually patching each one of them. So this commit adds tracesIndex/tracesEnabled alongside metricsIndex/metricsEnabled etc so the traces are exported as expected.
1 parent be3f7f6 commit daab50e

File tree

7 files changed

+84
-8
lines changed

7 files changed

+84
-8
lines changed

helm-charts/splunk-otel-collector/templates/_helpers.tpl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ Whether metrics enabled for Splunk Platform.
107107
{{- and (eq (include "splunk-otel-collector.splunkPlatformEnabled" .) "true") .Values.splunkPlatform.metricsEnabled }}
108108
{{- end -}}
109109

110+
{{/*
111+
Whether traces enabled for Splunk Platform.
112+
*/}}
113+
{{- define "splunk-otel-collector.platformTracesEnabled" -}}
114+
{{- and (eq (include "splunk-otel-collector.splunkPlatformEnabled" .) "true") .Values.splunkPlatform.tracesEnabled }}
115+
{{- end -}}
116+
110117
{{/*
111118
Whether metrics enabled for any destination.
112119
*/}}
@@ -115,10 +122,10 @@ Whether metrics enabled for any destination.
115122
{{- end -}}
116123

117124
{{/*
118-
Whether traces enabled for any destination. (currently applicable to Splunk Observability only).
125+
Whether traces enabled for any destination.
119126
*/}}
120127
{{- define "splunk-otel-collector.tracesEnabled" -}}
121-
{{- include "splunk-otel-collector.o11yTracesEnabled" . }}
128+
{{- or (eq (include "splunk-otel-collector.o11yTracesEnabled" .) "true") (eq (include "splunk-otel-collector.platformTracesEnabled" .) "true") }}
122129
{{- end -}}
123130

124131
{{/*

helm-charts/splunk-otel-collector/templates/config/_common.tpl

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ splunk_hec/platform_logs:
211211
{{- end }}
212212

213213
{{/*
214-
Splunk Platform Logs exporter
214+
Splunk Platform Metrics exporter
215215
*/}}
216216
{{- define "splunk-otel-collector.splunkPlatformMetricsExporter" -}}
217217
splunk_hec/platform_metrics:
@@ -246,6 +246,42 @@ splunk_hec/platform_metrics:
246246
queue_size: {{ .Values.splunkPlatform.sendingQueue.queueSize }}
247247
{{- end }}
248248

249+
{{/*
250+
Splunk Platform Traces exporter
251+
*/}}
252+
{{- define "splunk-otel-collector.splunkPlatformTracesExporter" -}}
253+
splunk_hec/platform_traces:
254+
endpoint: {{ .Values.splunkPlatform.endpoint | quote }}
255+
token: "${SPLUNK_PLATFORM_HEC_TOKEN}"
256+
index: {{ .Values.splunkPlatform.tracesIndex | quote }}
257+
source: {{ .Values.splunkPlatform.source | quote }}
258+
max_connections: {{ .Values.splunkPlatform.maxConnections }}
259+
disable_compression: {{ .Values.splunkPlatform.disableCompression }}
260+
timeout: {{ .Values.splunkPlatform.timeout }}
261+
splunk_app_name: {{ .Chart.Name }}
262+
splunk_app_version: {{ .Chart.Version }}
263+
tls:
264+
insecure_skip_verify: {{ .Values.splunkPlatform.insecureSkipVerify }}
265+
{{- if .Values.splunkPlatform.clientCert }}
266+
cert_file: /otel/etc/splunk_platform_hec_client_cert
267+
{{- end }}
268+
{{- if .Values.splunkPlatform.clientKey }}
269+
key_file: /otel/etc/splunk_platform_hec_client_key
270+
{{- end }}
271+
{{- if .Values.splunkPlatform.caFile }}
272+
ca_file: /otel/etc/splunk_platform_hec_ca_file
273+
{{- end }}
274+
retry_on_failure:
275+
enabled: {{ .Values.splunkPlatform.retryOnFailure.enabled }}
276+
initial_interval: {{ .Values.splunkPlatform.retryOnFailure.initialInterval }}
277+
max_interval: {{ .Values.splunkPlatform.retryOnFailure.maxInterval }}
278+
max_elapsed_time: {{ .Values.splunkPlatform.retryOnFailure.maxElapsedTime }}
279+
sending_queue:
280+
enabled: {{ .Values.splunkPlatform.sendingQueue.enabled }}
281+
num_consumers: {{ .Values.splunkPlatform.sendingQueue.numConsumers }}
282+
queue_size: {{ .Values.splunkPlatform.sendingQueue.queueSize }}
283+
{{- end }}
284+
249285
{{/*
250286
Add Extra Labels
251287
*/}}

helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ exporters:
587587
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" .) "true") }}
588588
{{- include "splunk-otel-collector.splunkPlatformMetricsExporter" . | nindent 2 }}
589589
{{- end }}
590+
{{- if (eq (include "splunk-otel-collector.platformTracesEnabled" .) "true") }}
591+
{{- include "splunk-otel-collector.splunkPlatformTracesExporter" . | nindent 2 }}
592+
{{- end }}
590593
{{- end }}
591594

592595
{{- if (eq (include "splunk-otel-collector.splunkO11yEnabled" .) "true") }}
@@ -698,7 +701,13 @@ service:
698701
{{- if (eq (include "splunk-otel-collector.tracesEnabled" .) "true") }}
699702
# Default traces pipeline.
700703
traces:
701-
receivers: [otlp, jaeger, smartagent/signalfx-forwarder, zipkin]
704+
receivers:
705+
- otlp
706+
- jaeger
707+
{{- if (eq (include "splunk-otel-collector.o11yTracesEnabled" $) "true") }}
708+
- smartagent/signalfx-forwarder
709+
{{- end }}
710+
- zipkin
702711
processors:
703712
- memory_limiter
704713
- k8sattributes
@@ -712,8 +721,13 @@ service:
712721
{{- if $gatewayEnabled }}
713722
- otlp
714723
{{- else }}
724+
{{- if (eq (include "splunk-otel-collector.o11yTracesEnabled" .) "true") }}
715725
- sapm
716726
{{- end }}
727+
{{- if (eq (include "splunk-otel-collector.platformTracesEnabled" .) "true") }}
728+
- splunk_hec/platform_traces
729+
{{- end }}
730+
{{- end }}
717731
{{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" $) "true") }}
718732
# For trace/metric correlation.
719733
- signalfx

helm-charts/splunk-otel-collector/templates/config/_otel-collector.tpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ exporters:
164164
{{- include "splunk-otel-collector.splunkPlatformMetricsExporter" . | nindent 2 }}
165165
{{- end }}
166166

167+
{{- if (eq (include "splunk-otel-collector.platformTracesEnabled" .) "true") }}
168+
{{- include "splunk-otel-collector.splunkPlatformTracesExporter" . | nindent 2 }}
169+
{{- end }}
167170
service:
168171
telemetry:
169172
metrics:
@@ -179,7 +182,7 @@ service:
179182
# The default pipelines should not need to be changed. You can add any custom pipeline instead.
180183
# In order to disable a default pipeline just set it to `null` in gateway.config overrides.
181184
pipelines:
182-
{{- if (eq (include "splunk-otel-collector.o11yTracesEnabled" $) "true") }}
185+
{{- if (eq (include "splunk-otel-collector.tracesEnabled" $) "true") }}
183186
# default traces pipeline
184187
traces:
185188
receivers: [otlp, jaeger, zipkin]
@@ -194,7 +197,13 @@ service:
194197
{{- if .Values.environment }}
195198
- resource/add_environment
196199
{{- end }}
197-
exporters: [sapm]
200+
exporters:
201+
{{- if (eq (include "splunk-otel-collector.o11yTracesEnabled" .) "true") }}
202+
- sapm
203+
{{- end }}
204+
{{- if (eq (include "splunk-otel-collector.platformTracesEnabled" .) "true") }}
205+
- splunk_hec/platform_traces
206+
{{- end }}
198207
{{- end }}
199208

200209
{{- if (eq (include "splunk-otel-collector.metricsEnabled" .) "true") }}

helm-charts/splunk-otel-collector/templates/daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ spec:
232232
{{- end }}
233233
ports:
234234
{{- range $key, $port := $agent.ports }}
235-
{{- if eq true (and (eq (include "splunk-otel-collector.metricsEnabled" $) "true") (has "metrics" $port.enabled_for)) (and (eq (include "splunk-otel-collector.o11yTracesEnabled" $) "true") (has "traces" $port.enabled_for)) (and (eq (include "splunk-otel-collector.logsEnabled" $) "true") (has "logs" $port.enabled_for)) (and (eq (include "splunk-otel-collector.profilingEnabled" $) "true") (has "profiling" $port.enabled_for)) }}
235+
{{- if eq true (and (eq (include "splunk-otel-collector.metricsEnabled" $) "true") (has "metrics" $port.enabled_for)) (and (eq (include "splunk-otel-collector.tracesEnabled" $) "true") (has "traces" $port.enabled_for)) (and (eq (include "splunk-otel-collector.logsEnabled" $) "true") (has "logs" $port.enabled_for)) (and (eq (include "splunk-otel-collector.profilingEnabled" $) "true") (has "profiling" $port.enabled_for)) }}
236236
- name: {{ $key }}
237237
{{- omit $port "enabled_for" | toYaml | trim | nindent 10 }}
238238
{{- end }}

helm-charts/splunk-otel-collector/values.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
"metricsIndex": {
4747
"type": "string"
4848
},
49+
"tracesIndex": {
50+
"type": "string"
51+
},
4952
"source": {
5053
"type": "string"
5154
},
@@ -81,6 +84,10 @@
8184
"description": "Send Metrics to Splunk Platform",
8285
"type": "boolean"
8386
},
87+
"tracesEnabled": {
88+
"description": "Send Traces to Splunk Platform",
89+
"type": "boolean"
90+
},
8491
"fieldNameConvention": {
8592
"type": "object",
8693
"additionalProperties": false,

helm-charts/splunk-otel-collector/values.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ splunkPlatform:
3535
index: "main"
3636
# Name of the Splunk metric type index targeted. Required when ingesting metrics to Splunk Platform.
3737
metricsIndex: ""
38+
# Name of the Splunk event type index targeted. Required when ingesting traces to Splunk Platform.
39+
tracesIndex: ""
3840
# Optional. Default value for `source` field.
3941
source: "kubernetes"
4042
# Optional. Default value for `sourcetype` field. For container logs, it will
@@ -67,7 +69,8 @@ splunkPlatform:
6769
logsEnabled: true
6870
# If you enable metrics collection, make sure that `metricsIndex` is provided as well.
6971
metricsEnabled: false
70-
72+
# If you enable traces collection, make sure that `tracesIndex` is provided as well.
73+
tracesEnabled: false
7174
# Field name conventions to use. (Only for those who are migrating from Splunk Connect for Kubernetes helm chart)
7275
fieldNameConvention:
7376
# Boolean for renaming pod metadata fields to match to Splunk Connect for Kubernetes helm chart.

0 commit comments

Comments
 (0)