-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[workloadmeta] Add support for "labels as tags" #9542
Conversation
releasenotes/notes/containerd-labels-as-tags-a04b95cdc9c63adf.yaml
Outdated
Show resolved
Hide resolved
9a7c5ba
to
5424676
Compare
5424676
to
0509a93
Compare
Rebased on top of master to get the latest changes in the workloadmeta code. |
0509a93
to
09b9166
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! ✅
Could you just update the PR description / testing section to mention that container_env_as_tags
and container_labels_as_tags
should support and be tested with advanced configs like '{"*":"<PREFIX>_%%label%%"}'
as documented here ? thanks!
@ahmed-mez I updated the PR description and testing instructions. |
* [config] Add container_labels_as_tags * [tagger/workloadmeta] Use container_labels_as_tags option * Add release note * [workloadmeta] Use utils.InitMetadataAsTags for container envs and labels
What does this PR do?
Introduces a new option "container_labels_as_tags" that allows the agent to extract container label values and set them as metric tags values. It's equivalent to the existing "docker_labels_as_tags", but it also works with containerd.
This PR also adds support for that new option in the tagger workloadmeta collector.
This PR also fixes a regression. The new containerd collector didn't support advanced options in env as tags like: '{"*":"_%%env%%"}'. That has been fixed.
Describe how to test your changes
This needs to be tested on Kubernetes. Also, this only works in containerd >= 1.5.6 because previous versions didn't propagate labels correctly. At the moment of writing this, kind does not come with that containerd version by default, but you can install it in a custom image like explained here: kubernetes-sigs/kind#1637 (comment)
DD_CONTAINER_LABELS_AS_TAGS
to: "{"test_label": "test_label_as_tag"}", for example.agent tagger-list
and verify that the tag "test_label_as_tag" has the value "test_val" in theworkloadmeta-container
section of the container that you deployed.DD_CONTAINER_ENV_AS_TAGS
to{"*":"ENVPREFIX_%%env%%"}
and setDD_CONTAINER_LABELS_AS_TAGS
to{"*":"LABELPREFIX_%%label%%"}
. You should see those prefixes inagent tagger-list
.Checklist
changelog/no-changelog
label has been applied.need-change/operator
andneed-change/helm
labels has been applied if applicable.team/..
label has been applied, if known.Triage
milestone is set.Note: Adding GitHub labels is only possible for contributors with write access.