Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/k8sattributes] Support name:tag@digest image name format #36131

Closed
zarbis opened this issue Nov 1, 2024 · 4 comments · Fixed by #36145
Closed

[processor/k8sattributes] Support name:tag@digest image name format #36131

zarbis opened this issue Nov 1, 2024 · 4 comments · Fixed by #36145
Labels
bug Something isn't working priority:p2 Medium processor/k8sattributes k8s Attributes processor

Comments

@zarbis
Copy link

zarbis commented Nov 1, 2024

Component(s)

processor/k8sattributes

What happened?

Description

For better integrity guarantees we've started using name:tag@digest image reference format (e.g. alpine:3.19@sha256:ae65dbf8749a7d4527648ccee1fa3deb6bfcae34cbc30fc67aa45c44dcaa90ee).

It doesn't seem to be part of OCI image spec, but many projects use it (for example Karpenter).

Steps to Reproduce

  • Deploy Pod with image alpine:3.19@sha256:ae65dbf8749a7d4527648ccee1fa3deb6bfcae34cbc30fc67aa45c44dcaa90ee
  • Create collector with k8sattributes processor:
processors:
  k8sattributes: 
    extract:
      metadata:
      - k8s.node.name
      - k8s.deployment.name
      - k8s.replicaset.name
      - k8s.daemonset.name
      - k8s.job.name
      - k8s.cronjob.name
      - k8s.statefulset.name
      - k8s.container.name
      - container.image.name
      - container.image.tag
  • Observe telemetry metadata

Expected Result

container.image.name: alpine
container.image.tag: 3.19

Actual Result

container.image.name: alpine:3.19@sha
container.image.tag: ae65dbf8749a7d4527648ccee1fa3deb6bfcae34cbc30fc67aa45c44dcaa90ee

So basically split happens on last colon, not the first one.

Collector version

0.107.0

Environment information

Environment

K8s: 1.29

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

@zarbis zarbis added bug Something isn't working needs triage New item requiring triage labels Nov 1, 2024
@zarbis zarbis changed the title Support name:tag@digest image name format [processor/k8sattributes] Support name:tag@digest image name format Nov 1, 2024
@github-actions github-actions bot added the processor/k8sattributes k8s Attributes processor label Nov 1, 2024
Copy link
Contributor

github-actions bot commented Nov 1, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@TylerHelmuth
Copy link
Member

This feels correct. The digest can instead be captured in container.image.id or container.image.repo_digests: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/container.md

@TylerHelmuth TylerHelmuth added priority:p2 Medium and removed needs triage New item requiring triage labels Nov 1, 2024
@zarbis
Copy link
Author

zarbis commented Nov 1, 2024

@TylerHelmuth indeed, you will get full content of ImageID from registry to digest in container.image.repo_digests, but image.name will still be incorrectly capturing @sha256 and image.tag would incorrectly be digest, regardless of capturing image.repo_digests.

Capturing image.repo_digests doesn't solve incorrect captures for name and tag.

@TylerHelmuth
Copy link
Member

@zarbis I meant fixing the captured fields to

container.image.name: alpine
container.image.tag: 3.19
image.repo_digests: sha256:ae65dbf8749a7d4527648ccee1fa3deb6bfcae34cbc30fc67aa45c44dcaa90ee

feels the most right

TylerHelmuth pushed a commit that referenced this issue Nov 25, 2024
…36145)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixed issue with `k8sattributesprocessor` where digest is not properly
separated from tag if both are present. used official docker library to
perform parsing.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
#36131

<!--Describe what testing was performed and which tests were added.-->
#### Testing
unit tests
integration/e2e tests

<!--Describe the documentation added.-->
#### Documentation
N/A. Fields are already described correctly, this is simply fixing
parsing logic

<!--Please delete paragraphs that you did not use before submitting.-->
shivanthzen pushed a commit to shivanthzen/opentelemetry-collector-contrib that referenced this issue Dec 5, 2024
…pen-telemetry#36145)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixed issue with `k8sattributesprocessor` where digest is not properly
separated from tag if both are present. used official docker library to
perform parsing.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#36131

<!--Describe what testing was performed and which tests were added.-->
#### Testing
unit tests
integration/e2e tests

<!--Describe the documentation added.-->
#### Documentation
N/A. Fields are already described correctly, this is simply fixing
parsing logic

<!--Please delete paragraphs that you did not use before submitting.-->
ZenoCC-Peng pushed a commit to ZenoCC-Peng/opentelemetry-collector-contrib that referenced this issue Dec 6, 2024
…pen-telemetry#36145)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixed issue with `k8sattributesprocessor` where digest is not properly
separated from tag if both are present. used official docker library to
perform parsing.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#36131

<!--Describe what testing was performed and which tests were added.-->
#### Testing
unit tests
integration/e2e tests

<!--Describe the documentation added.-->
#### Documentation
N/A. Fields are already described correctly, this is simply fixing
parsing logic

<!--Please delete paragraphs that you did not use before submitting.-->
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this issue Dec 17, 2024
…pen-telemetry#36145)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixed issue with `k8sattributesprocessor` where digest is not properly
separated from tag if both are present. used official docker library to
perform parsing.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#36131

<!--Describe what testing was performed and which tests were added.-->
#### Testing
unit tests
integration/e2e tests

<!--Describe the documentation added.-->
#### Documentation
N/A. Fields are already described correctly, this is simply fixing
parsing logic

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p2 Medium processor/k8sattributes k8s Attributes processor
Projects
None yet
2 participants