<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Variable based on Tags in Segments in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275886#M1991</link>
    <description>&lt;P&gt;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&amp;nbsp;&lt;A href="https://community.dynatrace.com/t5/DQL/Create-a-variable-with-the-values-of-a-specific-tag/m-p/218061/thread-id/135" target="_blank" rel="noopener"&gt;https://community.dynatrace.com/t5/DQL/Create-a-variable-with-the-values-of-a-specific-tag/m-p/218061/thread-id/135&lt;/A&gt;&amp;nbsp;but it's repeating the [AWS]IDs so it looks like we have multiples of one ID rather than individual IDs.&lt;/P&gt;&lt;P&gt;My original DQL was:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch dt.entity.host
| fieldsAdd tags
| expand tags
| fields tags&lt;/LI-CODE&gt;&lt;P&gt;And the solution from the above link that I tried was:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.entity.host
| expand tags
| summarize tags = collectDistinct(tags)
| expand tags
| parse tags, """((LD:tag (!&amp;lt;&amp;lt;'\\' ':') LD:value)|LD:tag)"""
| fields tag = replaceString(tag,"""\:""", ":"), value = replaceString(value, """\:""", ":")
| filter toString(tag) == "[AWS]ID"
| fields value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2025 19:43:54 GMT</pubDate>
    <dc:creator>StephenHughes</dc:creator>
    <dc:date>2025-04-24T19:43:54Z</dc:date>
    <item>
      <title>Variable based on Tags in Segments</title>
      <link>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275886#M1991</link>
      <description>&lt;P&gt;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&amp;nbsp;&lt;A href="https://community.dynatrace.com/t5/DQL/Create-a-variable-with-the-values-of-a-specific-tag/m-p/218061/thread-id/135" target="_blank" rel="noopener"&gt;https://community.dynatrace.com/t5/DQL/Create-a-variable-with-the-values-of-a-specific-tag/m-p/218061/thread-id/135&lt;/A&gt;&amp;nbsp;but it's repeating the [AWS]IDs so it looks like we have multiples of one ID rather than individual IDs.&lt;/P&gt;&lt;P&gt;My original DQL was:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch dt.entity.host
| fieldsAdd tags
| expand tags
| fields tags&lt;/LI-CODE&gt;&lt;P&gt;And the solution from the above link that I tried was:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.entity.host
| expand tags
| summarize tags = collectDistinct(tags)
| expand tags
| parse tags, """((LD:tag (!&amp;lt;&amp;lt;'\\' ':') LD:value)|LD:tag)"""
| fields tag = replaceString(tag,"""\:""", ":"), value = replaceString(value, """\:""", ":")
| filter toString(tag) == "[AWS]ID"
| fields value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 19:43:54 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275886#M1991</guid>
      <dc:creator>StephenHughes</dc:creator>
      <dc:date>2025-04-24T19:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Variable based on Tags in Segments</title>
      <link>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275888#M1992</link>
      <description>&lt;P&gt;Adding the dedup command at the end of your query might help.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch dt.entity.host
| expand tags
| summarize tags = collectDistinct(tags)
| expand tags
| parse tags, """((LD:tag (!&amp;lt;&amp;lt;'\\' ':') LD:value)|LD:tag)"""
| fields tag = replaceString(tag,"""\:""", ":"), value = replaceString(value, """\:""", ":")
| filter toString(tag) == "[AWS]ID"
| fields value
| dedup value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 19:50:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275888#M1992</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-04-24T19:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Variable based on Tags in Segments</title>
      <link>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275890#M1993</link>
      <description>&lt;P&gt;Thank you, that helped!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 19:59:48 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Variable-based-on-Tags-in-Segments/m-p/275890#M1993</guid>
      <dc:creator>StephenHughes</dc:creator>
      <dc:date>2025-04-24T19:59:48Z</dc:date>
    </item>
  </channel>
</rss>

