<?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 Re: Write a lookup query in DQL that uses the entity id to pull the host group in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/270022#M1708</link>
    <description>&lt;P&gt;Thank you both for the great responses.&amp;nbsp; In my case the entities I am starting with are kubernetes workloads, not hosts.&amp;nbsp; My first issue is joining the workload to a host and then the host to a host group.&amp;nbsp; I need some help with the "RUNS_ON" portion that takes the workload ID and finds the host its lives on.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Feb 2025 14:01:35 GMT</pubDate>
    <dc:creator>gdalessandro</dc:creator>
    <dc:date>2025-02-13T14:01:35Z</dc:date>
    <item>
      <title>Write a lookup query in DQL that uses the entity id to pull the host group</title>
      <link>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269932#M1697</link>
      <description>&lt;P&gt;I am trying to write a DQL query that starts on the dt.davis.problems events and uses the affected_entity_id field to lookup the dt.entity.host.group.name field.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 19:29:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269932#M1697</guid>
      <dc:creator>gdalessandro</dc:creator>
      <dc:date>2025-02-12T19:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Write a lookup query in DQL that uses the entity id to pull the host group</title>
      <link>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269937#M1698</link>
      <description>&lt;P&gt;Here is the example query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.davis.problems
| filter matchesValue(affected_entity_types,"dt.entity.host")
| expand affected_entity_ids
| join [ fetch dt.entity.host
  | fieldsAdd dt.entity.host_group=instance_of[dt.entity.host_group] 
  ], on:{left[affected_entity_ids]==right[id]}, fields:{dt.entity.host_group} 
| fieldsAdd entityName(dt.entity.host_group)
| summarize { affected_host_group_names = collectDistinct(dt.entity.host_group.name) }, by: { timestamp, display_id, event.description }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all I would filter only events which affected hosts. Because single problem can affect multiple hosts and they are stored as array (also with other types of entities), we need to use &lt;STRONG&gt;&lt;EM&gt;expand&lt;/EM&gt;&lt;/STRONG&gt; before we &lt;EM&gt;&lt;STRONG&gt;join&lt;/STRONG&gt;&lt;/EM&gt; with dt.entity.host.&amp;nbsp;&lt;BR /&gt;Using join will automatically eliminate from result set records referencing to non hosts.&amp;nbsp;&lt;BR /&gt;From dt.host.entity we need&amp;nbsp; to retrieve reference to host group which is stored in "instance_of[dt.entity.host_group]" relationship. Having it allows us to grab directly host group name using &lt;EM&gt;&lt;STRONG&gt;entityName&lt;/STRONG&gt;&lt;/EM&gt; function.&lt;BR /&gt;Single problem could affect hosts from different host groups, so if you want to have single record for each problem, &lt;EM&gt;&lt;STRONG&gt;summarize&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;is needed to collect array of host group names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 20:58:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269937#M1698</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-02-12T20:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Write a lookup query in DQL that uses the entity id to pull the host group</title>
      <link>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269965#M1699</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/74173"&gt;@gdalessandro&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Below is the query that will solve your probelm&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.davis.problems
| filter matchesValue(affected_entity_types,"dt.entity.host")
| expand  affected_entity_ids
| fieldsRename id = affected_entity_ids
| join [fetch dt.entity.host], on:id
| fieldsAdd right.hostGroupName&lt;/LI-CODE&gt;&lt;P&gt;Here is the result and the query in Notebook App.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="zaidbashir_0-1739431748123.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26393iC0BD2D6474C96F71/image-size/medium?v=v2&amp;amp;px=400" role="button" title="zaidbashir_0-1739431748123.png" alt="zaidbashir_0-1739431748123.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Explanation:&lt;BR /&gt;==&amp;gt;First I query the affected_entities, affected_entity_ids is an array that contains id of affected entities like Services Id, Process Group Id, Host Id. To target only Host Ids I &lt;STRONG&gt;expanded the&amp;nbsp;affected_entity_ids &lt;/STRONG&gt;Arraythat will put each affected id in a separate row and also i changed the name of affected_entity_ids to id (there is a reason why)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;==&amp;gt;Then i joined it with dt.entity.host where we will get two things entity.name &amp;amp; id.&lt;BR /&gt;==&amp;gt; The target for &lt;STRONG&gt;join &lt;/STRONG&gt;is id. (It matches the id of first query with the id of 2nd query).&lt;/P&gt;&lt;P&gt;==&amp;gt; Then added the host_group in the final result.&lt;BR /&gt;&lt;BR /&gt;Thanks, If you feel any issue, reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 07:35:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/269965#M1699</guid>
      <dc:creator>zaid-bashir</dc:creator>
      <dc:date>2025-02-13T07:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Write a lookup query in DQL that uses the entity id to pull the host group</title>
      <link>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/270022#M1708</link>
      <description>&lt;P&gt;Thank you both for the great responses.&amp;nbsp; In my case the entities I am starting with are kubernetes workloads, not hosts.&amp;nbsp; My first issue is joining the workload to a host and then the host to a host group.&amp;nbsp; I need some help with the "RUNS_ON" portion that takes the workload ID and finds the host its lives on.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 14:01:35 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Write-a-lookup-query-in-DQL-that-uses-the-entity-id-to-pull-the/m-p/270022#M1708</guid>
      <dc:creator>gdalessandro</dc:creator>
      <dc:date>2025-02-13T14:01:35Z</dc:date>
    </item>
  </channel>
</rss>

