<?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 Extract TAG values from hosts tags in DQL in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216140#M83</link>
    <description>&lt;P&gt;I am querying the list of hosts in our environment, i would need to also filter by presence of a tag and to see the tag name and value in a column of the resulting table,&lt;/P&gt;&lt;P&gt;I am using this query to start with:&lt;/P&gt;&lt;P&gt;fetch dt.entity.host&lt;BR /&gt;| fieldsAdd entity.type, tags&lt;BR /&gt;| filter matchesPhrase(tags,"Business Segment")&lt;/P&gt;&lt;P&gt;the fact is that&amp;nbsp;Business Segment tag can have multiple values, like Sales, IT, Finance, and each hosts has may tags and what i need is to extract the value of the&amp;nbsp;Business Segment tag into a separated column, to see a grid showing only IT, Finance or Sales in a column, after the host name and the host id,&lt;/P&gt;&lt;P&gt;how can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2023 20:24:13 GMT</pubDate>
    <dc:creator>DavidePiras</dc:creator>
    <dc:date>2023-06-26T20:24:13Z</dc:date>
    <item>
      <title>Extract TAG values from hosts tags in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216140#M83</link>
      <description>&lt;P&gt;I am querying the list of hosts in our environment, i would need to also filter by presence of a tag and to see the tag name and value in a column of the resulting table,&lt;/P&gt;&lt;P&gt;I am using this query to start with:&lt;/P&gt;&lt;P&gt;fetch dt.entity.host&lt;BR /&gt;| fieldsAdd entity.type, tags&lt;BR /&gt;| filter matchesPhrase(tags,"Business Segment")&lt;/P&gt;&lt;P&gt;the fact is that&amp;nbsp;Business Segment tag can have multiple values, like Sales, IT, Finance, and each hosts has may tags and what i need is to extract the value of the&amp;nbsp;Business Segment tag into a separated column, to see a grid showing only IT, Finance or Sales in a column, after the host name and the host id,&lt;/P&gt;&lt;P&gt;how can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 20:24:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216140#M83</guid>
      <dc:creator>DavidePiras</dc:creator>
      <dc:date>2023-06-26T20:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract TAG values from hosts tags in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216142#M84</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/39859"&gt;@DavidePiras&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the field tags is an array of multiple tags. You need to use the &lt;A href="https://www.dynatrace.com/support/help/shortlink/dql-commands#expand" target="_self"&gt;expand command&lt;/A&gt;&amp;nbsp;to expand it and then parse the key value information from the tag itself.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch dt.entity.host
| fieldsAdd entity.type,tags
| expand tags
| parse tags, """((LD:tag (!&amp;lt;&amp;lt;'\\' ':') LD:value)|LD:tag)"""
| fieldsAdd tagvalue = if(isNotNull(value), value)
| fieldsRemove value
| fields id, entity.type,tag, tagvalue&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;The parsing looks a bit complex, but it is already optimized for some edge cases I have observed so far.&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 20:44:39 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216142#M84</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-06-26T20:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract TAG values from hosts tags in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216143#M85</link>
      <description>&lt;P&gt;Amazing, thank you so much for the hint, this is my adapted final query and works quite well, appreciated your prompt answer Sinisa!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fetch dt.entity.host&lt;BR /&gt;| fieldsAdd grp=instance_of[dt.entity.host_group]&lt;BR /&gt;| fieldsAdd tags&lt;BR /&gt;| fieldsAdd monitoringMode&lt;BR /&gt;| expand tags&lt;BR /&gt;| parse tags, """((LD:tag (!&amp;lt;&amp;lt;'\\' ':') LD:value)|LD:tag)"""&lt;BR /&gt;| fieldsAdd tagvalue = if(isNotNull(value), value)&lt;BR /&gt;| fieldsRemove value&lt;BR /&gt;| lookup [fetch dt.entity.host_group],sourceField:grp,lookupField:id&lt;BR /&gt;| fields HostGroup=lookup.entity.name, HostName=entity.name, tags, monitoringMode, tag, BusinessSegment=tagvalue&lt;BR /&gt;| filter isNotNull(HostGroup)&lt;BR /&gt;| filter tag == "Business Segment"&lt;BR /&gt;| sort HostGroup ASC, HostName ASC&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 21:02:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/216143#M85</guid>
      <dc:creator>DavidePiras</dc:creator>
      <dc:date>2023-06-26T21:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extract TAG values from hosts tags in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/254732#M1162</link>
      <description>&lt;P&gt;Hello, I believe this is quite old comment but I am new to Dynatrace and was wondering if there are any documentation/guide available to help me understand the parsing command better that was used in the query here, thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 14:37:53 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Extract-TAG-values-from-hosts-tags-in-DQL/m-p/254732#M1162</guid>
      <dc:creator>SaiK</dc:creator>
      <dc:date>2024-09-02T14:37:53Z</dc:date>
    </item>
  </channel>
</rss>

