<?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 Adding a field with a relationship to another field in my query in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/224998#M279</link>
    <description>&lt;P&gt;I am trying to get a list of all the services affected by Davis problems and then add a field containing the host for each service. This is how I attempted to do it, but the fields that should contain host information are empty.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fetch events, from:now() - 4h&lt;BR /&gt;| filter event.kind == "DAVIS_PROBLEM"&lt;BR /&gt;| expand affected_entity_ids&lt;BR /&gt;| fields affected_entity_ids&lt;BR /&gt;| lookup [fetch dt.entity.host], sourceField:affected_entity_ids, lookupField:runs[dt.entity.service]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can offer a solution, I would be very grateful&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2023 15:49:32 GMT</pubDate>
    <dc:creator>Christian_</dc:creator>
    <dc:date>2023-10-10T15:49:32Z</dc:date>
    <item>
      <title>Adding a field with a relationship to another field in my query</title>
      <link>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/224998#M279</link>
      <description>&lt;P&gt;I am trying to get a list of all the services affected by Davis problems and then add a field containing the host for each service. This is how I attempted to do it, but the fields that should contain host information are empty.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fetch events, from:now() - 4h&lt;BR /&gt;| filter event.kind == "DAVIS_PROBLEM"&lt;BR /&gt;| expand affected_entity_ids&lt;BR /&gt;| fields affected_entity_ids&lt;BR /&gt;| lookup [fetch dt.entity.host], sourceField:affected_entity_ids, lookupField:runs[dt.entity.service]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can offer a solution, I would be very grateful&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 15:49:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/224998#M279</guid>
      <dc:creator>Christian_</dc:creator>
      <dc:date>2023-10-10T15:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a field with a relationship to another field in my query</title>
      <link>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/225001#M280</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/67605"&gt;@Christian_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following query should work for you&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch events, from:now()-7d
| filter event.kind == "DAVIS_PROBLEM"
| summarize {problem=takeMax(record(timestamp,affected_entity_ids) )}, by:{display_id}
| expand affected_entity_id=problem[affected_entity_ids]
| fields display_id, affected_entity_id
| filter startsWith(affected_entity_id, "SERVICE-")
| lookup
  [
    fetch dt.entity.service
    | fieldsAdd hosts = runs_on[dt.entity.host]
  ], sourceField:affected_entity_id, lookupField:id, fields:{hosts, entity.name}
| expand dt.entity.host = hosts
| filter isNotNull(dt.entity.host)
| fields display_id, affected_service = affected_entity_id,service_name=entity.name, affected_host =dt.entity.host&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;You can also try it out in &lt;A href="http://fetch%20events, from:now()-7d | filter event.kind == &amp;quot;DAVIS_PROBLEM&amp;quot; | summarize {problem=takeMax(record(timestamp,affected_entity_ids) )}, by:{display_id} | expand affected_entity_id=problem[affected_entity_ids] | fields display_id, affected_entity_id | filter startsWith(affected_entity_id, &amp;quot;SERVICE-&amp;quot;) | lookup   [     fetch dt.entity.service     | fieldsAdd hosts = runs_on[dt.entity.host]   ], sourceField:affected_entity_id, lookupField:id, fields:{hosts, entity.name} | expand dt.entity.host = hosts | filter isNotNull(dt.entity.host) | fields display_id, affected_service = affected_entity_id,service_name=entity.name, affected_host =dt.entity.host" target="_self"&gt;Discover Dynatrace&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 16:18:23 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/225001#M280</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-10-10T16:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a field with a relationship to another field in my query</title>
      <link>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/225066#M285</link>
      <description>&lt;P&gt;Yes, that worked perfectly, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 10:00:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Adding-a-field-with-a-relationship-to-another-field-in-my-query/m-p/225066#M285</guid>
      <dc:creator>Christian_</dc:creator>
      <dc:date>2023-10-11T10:00:13Z</dc:date>
    </item>
  </channel>
</rss>

