DataDog / chef-datadog

Chef cookbook for Datadog Agent & Integrations
https://www.datadoghq.com
Apache License 2.0
97 stars 261 forks source link

[BUG] default tag prefix `tag:` #932

Open rjhornsby opened 2 months ago

rjhornsby commented 2 months ago

Environment details (Operating System, Cloud provider, etc):

Rocky 9 Linux, AWS but not specifically relevant.

Describe what happened:

I'm not sure if this is a bug or just an unusual default behavior with maybe unintended consequences.

When asking Chef to tag a node, the default behavior for the chef-datadog cookbook is to prefix this tag with tag: before it is submitted to DD. A tag like chef-version:1.0.0 turns into tag:chef-version:1.0.0 when it reaches DD.

This causes issues searching and filtering hosts in DD by tag (concept), because the tag key is the string literal tag, while the value of the tag is chef-version:1.0.0. For example, when you tell DD you want to group by a tag key, what you get in the dropdown list is tag, not chef-version.

This UI behavior makes sense if the tag is split by the first : separator into key and value, which is how one would expect the split to happen.

Describe what you expected:

It's clear from attributes/default.rb that I can override this behavior. What's less clear is why this prefix is the default? I feel like I'm missing something obvious about the benefit of leaving the behavior as is.

Is there a downside or a hidden gotcha to setting the prefix to empty string?

Steps to reproduce the issue:

Set a tag on your node, for example in a recipe:

version_tag = "chef-version:#{node['chef_packages']['chef']['version']}"
tag(version_tag) unless tagged?(version_tag)

As per the behavior described in the attributes file, this will be prefixed by tag: