Combine Multiple Fetches in Dynatrace Query Language (DQL)

Summary: This article explains how to combine multiple fetch operations in a single DQL query. It includes syntax examples and best practices for optimising queries in Dynatrace dashboards.

Hi,

What is the syntax to create a union of two fetch statmenents, bascially wanted a result of both fetch queires in a single statement

fetch `dt.entity.palo-alto:device`
| fieldsAdd SystemName,deviceAddress,entity.type
| fieldsRename ipaddress=deviceAddress,devicename=SystemName,type=entity.type

fetch `dt.entity.snmp:com_dynatrace_extension_snmp_generic_cisco_device`
| fieldsAdd system_name,dt.ip_addresses,entity.type
| fieldsRename ipaddress=dt.ip_addresses,devicename=system_name,type=entity.type

Appreciate your response.

Thanks & Regards,

Rama

Hi @rchillara ,

the DQL equivalent for SQL union is the append command. The following query should work:

fetch `dt.entity.palo-alto:device`<br>| fieldsAdd SystemName,deviceAddress,entity.type<br>| fieldsRename ipaddress=deviceAddress,devicename=SystemName,type=entity.type<br>| append [<br>   fetch `dt.entity.snmp:com_dynatrace_extension_snmp_generic_cisco_device`<br>  | fieldsAdd system_name,dt.ip_addresses,entity.type<br>  | fieldsRename ipaddress=dt.ip_addresses,devicename=system_name,type=entity.type<br>]

@stefan_eggersto thank you.