<?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 Counting Problems by ManagementZone in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290089#M2815</link>
    <description>&lt;P&gt;I am able to get total Hosts, Services, Process Group, Custom Device, etcs by ManagementZone (MZ).&lt;BR /&gt;I am stuck trying to get total number problems associated by MZ (affected_entity_ids, and root_cause_entity_id).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;fetch dt.entity.service&lt;BR /&gt;| expand managementZones&lt;BR /&gt;| summarize by:{managementZones}, service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| append [ fetch dt.entity.host | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, Host = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.process_group | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, ProcessGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.application | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, Application = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.aws_lambda_function | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, AWS_lambda_function = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.aws_credentials | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, AWS_credential = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.http_check | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, http_check = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.custom_device | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, CustomDevice = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.custom_device_group | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, CustomDeviceGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.relational_database_service | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, relational_database = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.kubernetes_service | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, kubernetes_service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;// This is where I am having issue: How do I count problems (affected_entity_ids, and root_cause_entity_id) by management zone.&lt;BR /&gt;//&lt;BR /&gt;//| append [ fetch dt.davis.problems | expand affected_entity_ids | expand root_cause_entity_id | summarize by:{display_id}, AFService = countDistinct(display_id) ]&lt;BR /&gt;//&lt;BR /&gt;// Perhaps append then lookup with sourceField:affected_entity_ids and root_cause_entity_id ?&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| summarize by:{managementZones},&lt;BR /&gt;Hosts = if ( isNull(max(Host)), 0, else: max(Host) ),&lt;BR /&gt;Services = if ( isNull(max(service)), 0, else: max(service) ),&lt;BR /&gt;ProcessGrp = if ( isNull(max(ProcessGroup)), 0, else: max(ProcessGroup) ),&lt;BR /&gt;CustomDev = if ( isNull(max(CustomDevice)), 0, else: max(CustomDevice) ),&lt;BR /&gt;CustomDevGrp = if ( isNull(max(CustomDeviceGroup)), 0, else: max(CustomDeviceGroup) ),&lt;BR /&gt;Applications = if ( isNull(max(Application)), 0, else: max(Application) ),&lt;BR /&gt;AWS_lambda = if ( isNull(max(AWS_lambda_function)), 0, else: max(AWS_lambda_function) ),&lt;BR /&gt;AWS_credentials = if ( isNull(max(AWS_credential)), 0, else: max(AWS_credential) ),&lt;BR /&gt;k8s_services = if ( isNull(max(kubernetes_service)), 0, else: max(kubernetes_service) ),&lt;BR /&gt;RDB = if ( isNull(max(relational_database)), 0, else: max(relational_database) ),&lt;BR /&gt;http_checks = if ( isNull(max(http_check)), 0, else: max(http_check) )&lt;BR /&gt;&lt;BR /&gt;| filterOut isNull(managementZones)&lt;BR /&gt;| sort upper(managementZones) asc&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 23 Nov 2025 20:12:42 GMT</pubDate>
    <dc:creator>PVThach</dc:creator>
    <dc:date>2025-11-23T20:12:42Z</dc:date>
    <item>
      <title>Counting Problems by ManagementZone</title>
      <link>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290089#M2815</link>
      <description>&lt;P&gt;I am able to get total Hosts, Services, Process Group, Custom Device, etcs by ManagementZone (MZ).&lt;BR /&gt;I am stuck trying to get total number problems associated by MZ (affected_entity_ids, and root_cause_entity_id).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;fetch dt.entity.service&lt;BR /&gt;| expand managementZones&lt;BR /&gt;| summarize by:{managementZones}, service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| append [ fetch dt.entity.host | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, Host = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.process_group | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, ProcessGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.application | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, Application = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.aws_lambda_function | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, AWS_lambda_function = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.aws_credentials | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, AWS_credential = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.http_check | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, http_check = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.custom_device | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, CustomDevice = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.custom_device_group | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, CustomDeviceGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.relational_database_service | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, relational_database = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;BR /&gt;| append [ fetch dt.entity.kubernetes_service | expand managementZones | filterOut isNull(managementZones) | summarize by:{managementZones}, kubernetes_service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id)) ]&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;// This is where I am having issue: How do I count problems (affected_entity_ids, and root_cause_entity_id) by management zone.&lt;BR /&gt;//&lt;BR /&gt;//| append [ fetch dt.davis.problems | expand affected_entity_ids | expand root_cause_entity_id | summarize by:{display_id}, AFService = countDistinct(display_id) ]&lt;BR /&gt;//&lt;BR /&gt;// Perhaps append then lookup with sourceField:affected_entity_ids and root_cause_entity_id ?&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| summarize by:{managementZones},&lt;BR /&gt;Hosts = if ( isNull(max(Host)), 0, else: max(Host) ),&lt;BR /&gt;Services = if ( isNull(max(service)), 0, else: max(service) ),&lt;BR /&gt;ProcessGrp = if ( isNull(max(ProcessGroup)), 0, else: max(ProcessGroup) ),&lt;BR /&gt;CustomDev = if ( isNull(max(CustomDevice)), 0, else: max(CustomDevice) ),&lt;BR /&gt;CustomDevGrp = if ( isNull(max(CustomDeviceGroup)), 0, else: max(CustomDeviceGroup) ),&lt;BR /&gt;Applications = if ( isNull(max(Application)), 0, else: max(Application) ),&lt;BR /&gt;AWS_lambda = if ( isNull(max(AWS_lambda_function)), 0, else: max(AWS_lambda_function) ),&lt;BR /&gt;AWS_credentials = if ( isNull(max(AWS_credential)), 0, else: max(AWS_credential) ),&lt;BR /&gt;k8s_services = if ( isNull(max(kubernetes_service)), 0, else: max(kubernetes_service) ),&lt;BR /&gt;RDB = if ( isNull(max(relational_database)), 0, else: max(relational_database) ),&lt;BR /&gt;http_checks = if ( isNull(max(http_check)), 0, else: max(http_check) )&lt;BR /&gt;&lt;BR /&gt;| filterOut isNull(managementZones)&lt;BR /&gt;| sort upper(managementZones) asc&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Nov 2025 20:12:42 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290089#M2815</guid>
      <dc:creator>PVThach</dc:creator>
      <dc:date>2025-11-23T20:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Problems by ManagementZone</title>
      <link>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290108#M2816</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.entity.service
| expand managementZones
| summarize by:{managementZones}, service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))

| append [
    fetch dt.entity.host
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, Host = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.process_group
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, ProcessGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.application
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, Application = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.aws_lambda_function
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, AWS_lambda_function = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.aws_credentials
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, AWS_credential = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.http_check
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, http_check = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.custom_device
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, CustomDevice = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.custom_device_group
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, CustomDeviceGroup = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.relational_database_service
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, relational_database = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]
| append [
    fetch dt.entity.kubernetes_service
    | expand managementZones
    | filterOut isNull(managementZones)
    | summarize by:{managementZones}, kubernetes_service = if( isNull(countDistinct(id) ), 0, else: countDistinct(id))
]

//
// PROBLEMY – wg affected_entity_ids
//
| append [
    fetch dt.davis.problems
    | expand affected_entity_ids
    // podpinamy encje (tu: SERVICE) żeby z nich wyciągnąć managementZones
    | lookup sourceField:affected_entity_ids, lookupField:id, [
        fetch dt.entity.service
        | expand managementZones
        | filterOut isNull(managementZones)
    ]
    // lookup.managementZones -&amp;gt; normalne pole managementZones
    | expand `lookup.managementZones`, alias:managementZones
    | summarize by:{managementZones}, Problems_affected = countDistinct(display_id)
]

//
// PROBLEMY – wg root_cause_entity_id
//
| append [
    fetch dt.davis.problems
    | filter isNotNull(root_cause_entity_id) and root_cause_entity_id != ""
    | lookup sourceField:root_cause_entity_id, lookupField:id, [
        fetch dt.entity.service
        | expand managementZones
        | filterOut isNull(managementZones)
    ]
    | expand `lookup.managementZones`, alias:managementZones
    | summarize by:{managementZones}, Problems_root_cause = countDistinct(display_id)
]

| summarize by:{managementZones},
    Hosts              = if ( isNull(max(Host)), 0, else: max(Host) ),
    Services           = if ( isNull(max(service)), 0, else: max(service) ),
    ProcessGrp         = if ( isNull(max(ProcessGroup)), 0, else: max(ProcessGroup) ),
    CustomDev          = if ( isNull(max(CustomDevice)), 0, else: max(CustomDevice) ),
    CustomDevGrp       = if ( isNull(max(CustomDeviceGroup)), 0, else: max(CustomDeviceGroup) ),
    Applications       = if ( isNull(max(Application)), 0, else: max(Application) ),
    AWS_lambda         = if ( isNull(max(AWS_lambda_function)), 0, else: max(AWS_lambda_function) ),
    AWS_credentials    = if ( isNull(max(AWS_credential)), 0, else: max(AWS_credential) ),
    k8s_services       = if ( isNull(max(kubernetes_service)), 0, else: max(kubernetes_service) ),
    RDB                = if ( isNull(max(relational_database)), 0, else: max(relational_database) ),
    http_checks        = if ( isNull(max(http_check)), 0, else: max(http_check) ),
    Problems_affected  = if ( isNull(max(Problems_affected)), 0, else: max(Problems_affected) ),
    Problems_root_cause= if ( isNull(max(Problems_root_cause)), 0, else: max(Problems_root_cause) )

| filterOut isNull(managementZones)
| sort upper(managementZones) asc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="t_pawlak_0-1763976208961.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30986i85F39B5C329C711F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="t_pawlak_0-1763976208961.png" alt="t_pawlak_0-1763976208961.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Nov 2025 09:24:44 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290108#M2816</guid>
      <dc:creator>t_pawlak</dc:creator>
      <dc:date>2025-11-24T09:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Problems by ManagementZone</title>
      <link>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290253#M2822</link>
      <description>&lt;P&gt;Awesome.&amp;nbsp; Thank you.&amp;nbsp; The solution did give me the answer I was looking for.&lt;BR /&gt;I had made a minor change because of IDE warning:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    | expand `lookup.managementZones`, alias:managementZones&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    | fieldsAdd lookup.managementZones, alias:managementZones
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;The IDE warning:&lt;BR /&gt;&lt;EM&gt;Applying the expand command with an alias on an expression that's not of type array has the same effect as a `fieldsAdd` command. You can replace it with this.&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 14:24:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Counting-Problems-by-ManagementZone/m-p/290253#M2822</guid>
      <dc:creator>PVThach</dc:creator>
      <dc:date>2025-11-25T14:24:12Z</dc:date>
    </item>
  </channel>
</rss>

