Skip to content

Commit

Permalink
Fetch all attributes (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaphalak authored Nov 17, 2021
1 parent ff4e7ff commit 1558b3a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 11 deletions.
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ If you provide access token for Splunk Observability using a custom Kubernetes
secret (secter.create=false), please update the secret name from
`splunk_o11y_access_token` to `splunk_observability_access_token`

[#273 Changed configuration to fetch attributes from labels and annotations of pods and namespaces](https://github.com/signalfx/splunk-otel-collector-chart/pull/273)

The following parameter `podLabels` under the `extraAttributes` group is changed to `fromLabels`
This parameter needs to be updated in your custom values.yaml

## 0.36.2 to 0.37.0

[#232 Access to underlying node's filesystem was reduced to the minimum scope
Expand Down
4 changes: 4 additions & 0 deletions helm-charts/splunk-otel-collector/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ Splunk OpenTelemetry Connector is installed and configured to send data to Splun
[WARNING] "provider" parameter is deprecated, please use "cloudProvider" instead.
Upgrade guidelines: https://github.com/signalfx/splunk-otel-collector-chart/blob/main/UPGRADING.md#0371-to-0380
{{ end }}
{{- if not (eq (toString .Values.extraAttributes.podLabels) "<nil>") }}
[WARNING] ".Values.extraAttributes.podLabels" parameter is deprecated, please use ".Values.extraAttributes.fromLabels" instead.
Upgrade guidelines: https://github.com/signalfx/splunk-otel-collector-chart/blob/main/UPGRADING.md#0371-to-0380
{{ end }}
18 changes: 18 additions & 0 deletions helm-charts/splunk-otel-collector/templates/config/_common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,21 @@ splunk_hec/platform_metrics:
ca_file: /otel/etc/splunk_platform_hec_ca_file
{{- end }}
{{- end }}

{{/*
Add Extra Labels
*/}}
{{- define "splunk-otel-collector.addExtraLabels" -}}
{{- 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,11 +282,13 @@ processors:
- key: splunk.com/index
tag_name: com.splunk.index
from: pod
{{- with .Values.extraAttributes.podLabels }}
{{- include "splunk-otel-collector.addExtraAnnotations" . | nindent 8 }}
{{- if or .Values.extraAttributes.podLabels .Values.extraAttributes.fromLabels }}
labels:
{{- range . }}
{{- range .Values.extraAttributes.podLabels }}
- key: {{ . }}
{{- end }}
{{- include "splunk-otel-collector.addExtraLabels" . | nindent 8 }}
{{- end }}
{{- if eq .Values.logsEngine "fluentd" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ processors:
- key: splunk.com/index
tag_name: com.splunk.index
from: pod
{{- with .Values.extraAttributes.podLabels }}
{{- include "splunk-otel-collector.addExtraAnnotations" . | nindent 8 }}
{{- if or .Values.extraAttributes.podLabels .Values.extraAttributes.fromLabels }}
labels:
{{- range . }}
{{- range .Values.extraAttributes.podLabels }}
- key: {{ . }}
{{- end }}
{{- include "splunk-otel-collector.addExtraLabels" . | nindent 8 }}
{{- end }}

{{- include "splunk-otel-collector.resourceLogsProcessor" . | 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 @@ -234,6 +234,18 @@
"type": "string"
}
},
"fromLabels": {
"type": "array",
"items": {
"type": "object"
}
},
"fromAnnotations": {
"type": "array",
"items": {
"type": "object"
}
},
"custom": {
"type": "array",
"items": {
Expand Down
31 changes: 24 additions & 7 deletions helm-charts/splunk-otel-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,30 @@ autodetect:

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 pods (or namespaces) (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.<pod|namespace>.labels.<label_name>: <label_value>
# For example, if you want to collect "my_key" label from your namespaces, you could use the following:
# fromLabels:
# - key: my_key
# from: namespace
# If you want to collect all labels from your pods, you could do that using a `key_regex: .*` option, e.g.:
# fromLabels:
# - key_regex: .*
# from: pod
# If you want to change the default attribute name `k8s.pod.labels.<label_name>`, you could do that using a `tag_name` field:
# fromLabels:
# - key: my_key
# tag_name: my_tag
# from: pod
fromLabels:
- key: app

# Annotations that will be collected from k8s pods (or namespaces) (in case they are set)
# and added as extra attributes to the telemetry in the following format:
# k8s.<pod|namespace>.annotations.<annotation_name>: <annotation_value>
# fromAnnotations uses the same extraction rules as fromLabels option so refer examples from the fromLabels option.
fromAnnotations: []

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

0 comments on commit 1558b3a

Please sign in to comment.