Skip to content

Commit

Permalink
Extract container.image.tag attribute from container.image.name
Browse files Browse the repository at this point in the history
Update k8sClusterReceiver component to export `container.image.tag` attribute from `container.image.name` according to OpenTelemetry semantic conventions https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/resource/semantic_conventions/container.md

This can be removed once this issue open-telemetry/opentelemetry-collector-contrib#6314 is resolved
  • Loading branch information
dmitryax committed Nov 15, 2021
1 parent 07612d8 commit 8c9b3a4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Field name compatibility for SCK (#258)

### Changed

- Extract `container.image.tag` attribute from `container.image.name` (#285)

### Removed

- Busybox image dependency (#275)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ processors:
key: {{ .name }}
value: {{ .value }}
{{- end }}
# Extract "container.image.tag" attribute from "container.image.name" here until k8scluster
# receiver does it natively.
- key: container.image.name
pattern: ^(?P<container_image_name>[^\:]+)(?:\:(?P<container_image_tag>.*))?
action: extract
- key: container.image.name
from_attribute: container_image_name
action: upsert
- key: container_image_name
action: delete
- key: container.image.tag
from_attribute: container_image_tag
action: upsert
- key: container_image_tag
action: delete

exporters:
{{- if eq (include "splunk-otel-collector.o11yMetricsEnabled" $) "true" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ data:
- action: upsert
key: k8s.cluster.name
value: CHANGEME
- action: extract
key: container.image.name
pattern: ^(?P<container_image_name>[^\:]+)(?:\:(?P<container_image_tag>.*))?
- action: upsert
from_attribute: container_image_name
key: container.image.name
- action: delete
key: container_image_name
- action: upsert
from_attribute: container_image_tag
key: container.image.tag
- action: delete
key: container_image_tag
resource/add_collector_k8s:
attributes:
- action: insert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
component: otel-k8s-cluster-receiver
release: default
annotations:
checksum/config: 0482b5c8dc6f8b2b65eaca8979490e13ddffaa7ef323cf330677deee0e635b5e
checksum/config: c77ad0b36c4dd8182418b2149d996143bac0dc03f2036aad1410acef22c75eec
spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ data:
- action: upsert
key: k8s.cluster.name
value: CHANGEME
- action: extract
key: container.image.name
pattern: ^(?P<container_image_name>[^\:]+)(?:\:(?P<container_image_tag>.*))?
- action: upsert
from_attribute: container_image_name
key: container.image.name
- action: delete
key: container_image_name
- action: upsert
from_attribute: container_image_tag
key: container.image.tag
- action: delete
key: container_image_tag
resource/add_collector_k8s:
attributes:
- action: insert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
component: otel-k8s-cluster-receiver
release: default
annotations:
checksum/config: 0482b5c8dc6f8b2b65eaca8979490e13ddffaa7ef323cf330677deee0e635b5e
checksum/config: c77ad0b36c4dd8182418b2149d996143bac0dc03f2036aad1410acef22c75eec
spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
Expand Down

0 comments on commit 8c9b3a4

Please sign in to comment.