Skip to content

Commit

Permalink
add support for pod and namespace labels and annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaphalak committed Nov 17, 2021
1 parent 8a59ffc commit dbd80f0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 16 deletions.
3 changes: 3 additions & 0 deletions helm-charts/splunk-otel-collector/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ Splunk OpenTelemetry Connector is installed and configured to send data to Splun
[WARNING] "logsEnabled" parameter is deprecated, please use "splunkObservability.logsEnabled" instead.
Upgrade guidelines: https://github.com/signalfx/splunk-otel-collector-chart/blob/main/UPGRADING.md#0353-to-0360
{{ end }}
{{- if not (eq (toString .Values.extraAttributes.podLabels) "<nil>") }}
[WARNING] ".Values.extraAttributes.podLabels" parameter is deprecated, please use ".Values.extraAttributes.fromLabels" instead.
{{ end }}
19 changes: 19 additions & 0 deletions helm-charts/splunk-otel-collector/templates/config/_common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,22 @@ splunk_hec/platform_metrics:
ca_file: /otel/etc/splunk_platform_hec_ca_file
{{- end }}
{{- end }}

{{/*
Add Extra Labels
*/}}
{{- define "splunk-otel-collector.addExtraLabels" -}}
labels:
{{- with .Values.extraAttributes.fromLabels }}
{{ . | toYaml}}
{{- end }}
{{- end }}

{{/*
Add Extra Annotations
*/}}
{{- define "splunk-otel-collector.addExtraAnnotations" -}}
{{- with .Values.extraAttributes.fromAnnotations }}
{{ . | toYaml}}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,8 @@ processors:
- key: splunk.com/index
tag_name: com.splunk.index
from: pod
{{- with .Values.extraAttributes.podLabels }}
labels:
{{- range . }}
- key: {{ . }}
{{- end }}
{{- end }}
{{- include "splunk-otel-collector.addExtraAnnotations" . | nindent 8 }}
{{- include "splunk-otel-collector.addExtraLabels" . | nindent 6 }}
{{- if eq .Values.logsEngine "fluentd" }}
# Move flat fluentd logs attributes to resource attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ processors:
- key: splunk.com/index
tag_name: com.splunk.index
from: pod
{{- with .Values.extraAttributes.podLabels }}
labels:
{{- range . }}
- key: {{ . }}
{{- end }}
{{- end }}
{{- include "splunk-otel-collector.addExtraAnnotations" . | nindent 8 }}
{{- include "splunk-otel-collector.addExtraLabels" . | nindent 6 }}

{{- include "splunk-otel-collector.resourceLogsProcessor" . | nindent 2 }}
{{- include "splunk-otel-collector.filterLogsProcessors" . | nindent 2 }}
Expand Down
12 changes: 12 additions & 0 deletions helm-charts/splunk-otel-collector/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@
"type": "string"
}
},
"fromLabels": {
"type": "array",
"items": {
"type": "object"
}
},
"fromAnnotations": {
"type": "array",
"items": {
"type": "object"
}
},
"custom": {
"type": "array",
"items": {
Expand Down
17 changes: 13 additions & 4 deletions helm-charts/splunk-otel-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,19 @@ extraAttributes:
# Labels that will be collected from k8s pods (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.pod.labels.<label_name>: <label_value>
podLabels:
- app
# - k8s-app
# - release
# Labels that will be collected from k8s namespaces (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.namespace.labels.<label_name>: <label_value>
fromLabels:
- key: app

# Annotations that will be collected from k8s pods (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.pod.annotations.<annotation_name>: <annotation_value>
# Annotations that will be collected from k8s namespaces (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.namespace.annotations.<annotation_name>: <annotation_value>
fromAnnotations: []

# List of hardcoded key/value pairs that will be added as attributes to
# all the telemetry.
Expand Down

0 comments on commit dbd80f0

Please sign in to comment.