-
Notifications
You must be signed in to change notification settings - Fork 151
/
_otel-k8s-cluster-receiver-config.tpl
355 lines (329 loc) · 12.3 KB
/
_otel-k8s-cluster-receiver-config.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{{/*
Config for the otel-collector k8s cluster receiver deployment.
The values can be overridden in .Values.clusterReceiver.config
*/}}
{{- define "splunk-otel-collector.clusterReceiverConfig" -}}
{{ $clusterReceiver := fromYaml (include "splunk-otel-collector.clusterReceiver" .) -}}
extensions:
health_check:
endpoint: 0.0.0.0:13133
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
# k8s_observer w/ pod and node detection for eks/fargate deployment
k8s_observer:
auth_type: serviceAccount
observe_pods: true
observe_nodes: true
{{- end }}
receivers:
# Prometheus receiver scraping metrics from the pod itself
{{- include "splunk-otel-collector.prometheusInternalMetrics" "k8s-cluster-receiver" | nindent 2}}
k8s_cluster:
auth_type: serviceAccount
{{- if eq (include "splunk-otel-collector.o11yMetricsEnabled" $) "true" }}
metadata_exporters: [signalfx]
{{- end }}
{{- if eq (include "splunk-otel-collector.distribution" .) "openshift" }}
distribution: openshift
{{- end }}
{{- if and (eq (include "splunk-otel-collector.objectsEnabled" .) "true") (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
k8sobjects:
auth_type: serviceAccount
objects: {{ .Values.clusterReceiver.k8sObjects | toYaml | nindent 6 }}
{{- end }}
{{- if and $clusterReceiver.eventsEnabled (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
k8s_events:
auth_type: serviceAccount
{{- end }}
{{- if eq (include "splunk-otel-collector.o11yInfraMonEventsEnabled" .) "true" }}
smartagent/kubernetes-events:
type: kubernetes-events
alwaysClusterReporter: true
whitelistedEvents:
- reason: Created
involvedObjectKind: Pod
- reason: Unhealthy
involvedObjectKind: Pod
- reason: Failed
involvedObjectKind: Pod
- reason: FailedCreate
involvedObjectKind: Job
{{- end }}
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
# dynamically created kubeletstats receiver to report all Fargate "node" kubelet stats
# with exception of collector "node's" own since Fargate forbids connection.
receiver_creator:
receivers:
kubeletstats:
rule: type == "k8s.node" && name contains "fargate"
config:
auth_type: serviceAccount
collection_interval: 10s
endpoint: "`endpoint`:`kubelet_endpoint_port`"
extra_metadata_labels:
- container.id
metric_groups:
- container
- pod
- node
watch_observers:
- k8s_observer
{{- end }}
processors:
{{- include "splunk-otel-collector.otelMemoryLimiterConfig" . | nindent 2 }}
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
{{- include "splunk-otel-collector.k8sAttributesSplunkPlatformMetrics" . | nindent 2 }}
filter:
node_from_env_var: K8S_NODE_NAME
{{- end }}
batch:
send_batch_max_size: 32768
{{- include "splunk-otel-collector.resourceDetectionProcessor" . | nindent 2 }}
{{- if eq (include "splunk-otel-collector.autoDetectClusterName" .) "true" }}
{{- include "splunk-otel-collector.resourceDetectionProcessorKubernetesClusterName" . | nindent 2 }}
{{- end }}
{{- if eq (include "splunk-otel-collector.o11yInfraMonEventsEnabled" .) "true" }}
resource/add_event_k8s:
attributes:
- action: insert
key: kubernetes_cluster
value: {{ .Values.clusterName }}
{{- end }}
{{- if and $clusterReceiver.eventsEnabled (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
# Drop high cardinality k8s event attributes
attributes/drop_event_attrs:
actions:
- key: k8s.event.start_time
action: delete
- key: k8s.event.name
action: delete
- key: k8s.event.uid
action: delete
{{- end }}
{{- if and (eq (include "splunk-otel-collector.objectsEnabled" .) "true") (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
transform/add_sourcetype:
log_statements:
- context: log
statements:
- set(resource.attributes["com.splunk.sourcetype"], Concat(["kube:object:", attributes["k8s.resource.name"]], ""))
{{- end }}
{{- if or
(and $clusterReceiver.eventsEnabled (eq (include "splunk-otel-collector.logsEnabled" .) "true"))
(and (eq (include "splunk-otel-collector.objectsEnabled" .) "true") (eq (include "splunk-otel-collector.logsEnabled" .) "true"))
(eq (include "splunk-otel-collector.o11yInfraMonEventsEnabled" .) "true")
}}
{{- include "splunk-otel-collector.k8sClusterReceiverAttributesProcessor" . | nindent 2 }}
{{- end }}
# Resource attributes specific to the collector itself.
resource/add_collector_k8s:
attributes:
- action: insert
key: k8s.node.name
value: "${K8S_NODE_NAME}"
- action: insert
key: k8s.pod.name
value: "${K8S_POD_NAME}"
- action: insert
key: k8s.pod.uid
value: "${K8S_POD_UID}"
- action: insert
key: k8s.namespace.name
value: "${K8S_NAMESPACE}"
resource:
attributes:
# TODO: Remove once available in mapping service.
- action: insert
key: metric_source
value: kubernetes
{{- if .Values.clusterName }}
- action: upsert
key: k8s.cluster.name
value: {{ .Values.clusterName }}
{{- end }}
{{- range .Values.extraAttributes.custom }}
- action: upsert
key: {{ .name }}
value: {{ .value }}
{{- end }}
{{- if and ( eq ( include "splunk-otel-collector.objectsOrEventsEnabled" . ) "true") .Values.environment }}
resource/add_environment:
attributes:
- action: insert
key: deployment.environment
value: "{{ .Values.environment }}"
{{- end }}
resource/k8s_cluster:
attributes:
# XXX: Added so that Smart Agent metrics and OTel metrics don't map to the same MTS identity
# (same metric and dimension names and values) after mappings are applied. This would be
# the case if somebody uses the same cluster name from Smart Agent and OTel in the same org.
- action: insert
key: receiver
value: k8scluster
exporters:
{{- if or (eq (include "splunk-otel-collector.o11yMetricsEnabled" $) "true") (eq (include "splunk-otel-collector.o11yInfraMonEventsEnabled" .) "true") }}
signalfx:
ingest_url: {{ include "splunk-otel-collector.o11yIngestUrl" . }}
api_url: {{ include "splunk-otel-collector.o11yApiUrl" . }}
access_token: ${SPLUNK_OBSERVABILITY_ACCESS_TOKEN}
timeout: 10s
{{- if not (eq (include "splunk-otel-collector.distribution" .) "eks/fargate") }}
disable_default_translation_rules: true
{{- end}}
{{- end }}
{{- if and (eq (include "splunk-otel-collector.o11yLogsEnabled" .) "true") (eq (include "splunk-otel-collector.objectsOrEventsEnabled" .) "true") }}
splunk_hec/o11y:
endpoint: {{ include "splunk-otel-collector.o11yIngestUrl" . }}/v1/log
token: "${SPLUNK_OBSERVABILITY_ACCESS_TOKEN}"
log_data_enabled: true
profiling_data_enabled: false
# Temporary disable compression until 0.68.0 to workaround a compression bug
disable_compression: true
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" .) "true") }}
{{- include "splunk-otel-collector.splunkPlatformMetricsExporter" . | nindent 2 }}
{{- end }}
{{- if and (eq (include "splunk-otel-collector.platformLogsEnabled" .) "true") (eq (include "splunk-otel-collector.objectsOrEventsEnabled" .) "true") }}
{{- include "splunk-otel-collector.splunkPlatformLogsExporter" . | nindent 2 }}
{{- if $clusterReceiver.eventsEnabled }}
sourcetype: kube:events
{{- end }}
{{- end }}
service:
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: localhost
port: 8889
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
extensions: [health_check, k8s_observer]
{{- else }}
extensions: [health_check]
{{- end }}
pipelines:
{{- if or (eq (include "splunk-otel-collector.o11yMetricsEnabled" $) "true") (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
# k8s metrics pipeline
metrics:
receivers: [k8s_cluster]
processors:
- memory_limiter
- batch
{{- if eq (include "splunk-otel-collector.autoDetectClusterName" .) "true" }}
- resourcedetection/k8s_cluster_name
{{- end }}
- resource
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- k8sattributes/metrics
{{- end }}
- resource/k8s_cluster
exporters:
{{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }}
- signalfx
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- splunk_hec/platform_metrics
{{- end }}
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
metrics/eks:
receivers: [receiver_creator]
processors:
- memory_limiter
- batch
{{- if eq (include "splunk-otel-collector.autoDetectClusterName" .) "true" }}
- resourcedetection/k8s_cluster_name
{{- end }}
- resource
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- k8sattributes/metrics
{{- end }}
exporters:
{{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }}
- signalfx
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- splunk_hec/platform_metrics
{{- end }}
{{- end }}
# Pipeline for metrics collected about the collector pod itself.
metrics/collector:
receivers: [prometheus/k8s_cluster_receiver]
processors:
- memory_limiter
- batch
- resource/add_collector_k8s
- resourcedetection
- resource
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- k8sattributes/metrics
{{- end }}
exporters:
{{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }}
- signalfx
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }}
- splunk_hec/platform_metrics
{{- end }}
{{- end }}
{{- if and $clusterReceiver.eventsEnabled (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
logs:
receivers:
- k8s_events
processors:
- memory_limiter
- batch
- attributes/drop_event_attrs
- resourcedetection
- resource
{{- if .Values.environment }}
- resource/add_environment
{{- end }}
- k8sattributes/clusterReceiver
exporters:
{{- if (eq (include "splunk-otel-collector.o11yLogsEnabled" .) "true") }}
- splunk_hec/o11y
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformLogsEnabled" .) "true") }}
- splunk_hec/platform_logs
{{- end }}
{{- end }}
{{- if and (eq (include "splunk-otel-collector.objectsEnabled" .) "true") (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
logs/objects:
receivers:
- k8sobjects
processors:
- memory_limiter
- batch
- resourcedetection
- resource
- transform/add_sourcetype
{{- if .Values.environment }}
- resource/add_environment
{{- end }}
- k8sattributes/clusterReceiver
exporters:
{{- if (eq (include "splunk-otel-collector.o11yLogsEnabled" .) "true") }}
- splunk_hec/o11y
{{- end }}
{{- if (eq (include "splunk-otel-collector.platformLogsEnabled" .) "true") }}
- splunk_hec/platform_logs
{{- end }}
{{- end }}
{{- if eq (include "splunk-otel-collector.o11yInfraMonEventsEnabled" .) "true" }}
logs/events:
receivers:
- smartagent/kubernetes-events
processors:
- memory_limiter
- batch
- resourcedetection
- resource
{{- if .Values.clusterName }}
- resource/add_event_k8s
{{- end }}
- k8sattributes/clusterReceiver
exporters:
- signalfx
{{- end }}
{{- end }}