datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

Duplicating tag SERVICE

Open sfreidin-jiji opened this issue 5 years ago • 8 comments

Describe what happened: In docker-compose environment, tag short_image is duplicating tags service and source even if they set into labels in docker-compose.yml For example, we see:

short_name: foo
service: foo
service: bar
source: foo
source: bar

Describe what you expected: We would like to override tag service by our custom value from labels:

short_name: foo
service: bar
source: bar

where bar is placed in docker labels

Steps to reproduce the issue:

Additional environment details (Operating System, Cloud provider, etc):

sfreidin-jiji avatar Aug 11 '21 07:08 sfreidin-jiji

Hey @sfreidin-jiji

Is it happening on your logs? Do you see the duplicated tags in the logs UI for specific container logs?

Simwar avatar Aug 16 '21 15:08 Simwar

Yes , that what i see in the UI Screenshot at Aug 17 09-06-37

sfreidin-jiji avatar Aug 17 '21 06:08 sfreidin-jiji

I can confirm this is happening on AWS ECS , service tag is getting crunched, along with source.

ghost avatar Oct 07 '21 19:10 ghost

Also hitting this bug.

Looking at the source I suspect this is the issue:

$ rg 'if sourceName' -A 2 pkg/logs/launchers/container/tailerfactory/defaults.go
99:	if sourceName == "" {
100-		sourceName = shortName
101-	}

I suspect (unconfirmed) that this code is evaluated before DD_CONTAINER_LABELS_AS_TAGS parsing takes place, therefore source is set to the shortName (shortName is set from ShortImage).

After this DD_CONTAINER_LABELS_AS_TAGS parsing takes place which sets source again.

You end up with source set twice, first as a duplicate of short_image and later from the docker labels.

We can confirm in our setup that the duplicate (incorrect) source value always matches short_image.

More generally its unclear to me if allowing duplicate keys in tags is a design goal or not. As a programmer allowing a hash/map/dict/k-v store to have duplicate keys seems strange but ...

donovan avatar May 07 '25 02:05 donovan

This issue has been automatically marked as stale because it has not had activity in the past 15 days.

It will be closed in 30 days if no further activity occurs. If this issue is still relevant, adding a comment will keep it open. Also, you can always reopen the issue if you missed the window.

Thank you for your contributions!

dd-octo-sts avatar Oct 20 '25 22:10 dd-octo-sts

Can confirm we're seeing this on GKE as well, but it's not consistent through all our workloads. Datadog only allows filtering by one of the two tag values, so for a few services we actually get the incorrect service name which completely breaks unified service tagging for them. Both source and short_image evaluate to the container image, and despite having config to pull the service tag from labels, the service gets set as both the short image AND the resultant value of the service tag, instead of one clobbering the other. I'm not really sure how to work around this.

rgelinas-polygon avatar Oct 22 '25 20:10 rgelinas-polygon

Hi @rgelinas-polygon,

Thank you for taking the time to share your feedback. We recently introduced a system to help manage long-standing issues through automated stale management. We understand this may have come as a surprise for some existing issues. We want to apologize if it felt that way. It was not our intent, and we want to reassure you that every issue is important to us and reviewed carefully. For your specific issue, we’re reviewing it to ensure the discussion progresses and receives the right level of attention. Thank you for helping improve the Datadog Agent.

— The Datadog Agent Team

chouetz avatar Nov 12 '25 18:11 chouetz

Hi all,

Thanks for sharing the details around the tagging conflicts you’re seeing in the logs product. As @donovan mentioned, there is a fallback mechanism that can populate the service tag using the shortImage name. That said, it’s possible there are some edge-case race conditions between the tagger initialization and when log tailing begins.

One way to ensure the correct tags are applied to logs is to use the logs_config.tagger_warmup_duration configuration option. This setting tells the Agent to wait X seconds before finalizing a service’s log integration with tag metadata and scheduling it for tailing. The tradeoff is that log collection for the service will be delayed by that amount of time. We'd recommend setting this value somewhere between 1–5 seconds.

We’re also happy to continue investigating this behavior, but additional details about your Agent configuration and environment would be very helpful. If possible, please consider opening a support case through our helpdesk system (no login required) and including an Agent flare so we can better identify and prioritize any issues related to service tagging in logs. In the meanwhile, I am going to close this issue but please feel free to comment any further updates. Thanks all!

— The Datadog Agent Team

gabedos avatar Jan 06 '26 21:01 gabedos