cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Variable based on Tags in Segments

StephenHughes
Visitor

I would like to create a variable to be used in a segment that lets me filter based on tags. The idea is the tag is [AWS]ID and the values are X, Y, Z, I want to be able to filter by X,Y,Z and get their related hosts. I attempted to use the solution in https://community.dynatrace.com/t5/DQL/Create-a-variable-with-the-values-of-a-specific-tag/m-p/21806... but it's repeating the [AWS]IDs so it looks like we have multiples of one ID rather than individual IDs.

My original DQL was:

fetch dt.entity.host
| fieldsAdd tags
| expand tags
| fields tags

And the solution from the above link that I tried was:

fetch dt.entity.host
| expand tags
| summarize tags = collectDistinct(tags)
| expand tags
| parse tags, """((LD:tag (!<<'\\' ':') LD:value)|LD:tag)"""
| fields tag = replaceString(tag,"""\:""", ":"), value = replaceString(value, """\:""", ":")
| filter toString(tag) == "[AWS]ID"
| fields value

 

2 REPLIES 2

marco_irmer
Champion

Adding the dedup command at the end of your query might help.

fetch dt.entity.host
| expand tags
| summarize tags = collectDistinct(tags)
| expand tags
| parse tags, """((LD:tag (!<<'\\' ':') LD:value)|LD:tag)"""
| fields tag = replaceString(tag,"""\:""", ":"), value = replaceString(value, """\:""", ":")
| filter toString(tag) == "[AWS]ID"
| fields value
| dedup value

 

StephenHughes
Visitor

Thank you, that helped!

Featured Posts