cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pro-Tip: DQL Query Snippets Collection

r_weber
DynaMight Champion
DynaMight Champion

I started to collect various useful DQL query snippets to make it easier for users to get started with DQL. Internally I did this on a notebook, but I also wanted to share this with the community and lete everybody contribute their snippets as well. So why not on an ongoing thread here.

One reply for each snippet and use case, with a little description and a screenshot.

Certified Dynatrace Master, Dynatrace Partner - 360Performance.net
5 REPLIES 5

r_weber
DynaMight Champion
DynaMight Champion

Honeycomb representation of specific service's health status

This code snippet creates a honeycomb visualization (like we had on old dashboards) of the service health status. It uses a) the service entity information and the existing davis problem events and combines them. You can filter services by tags (e.g. a dt.owner tag).

 

r_weber_0-1725607634976.png

To get red/green status indicators, set the color mapping in the honeycomb visualization:

r_weber_1-1725607962464.png

 

DQL Query:

 

fetch dt.entity.service, from: -30m
| filter arrayIndexOf(entityAttr(type:"dt.entity.service",id, "tags"),"dt.owner:purchase") > -1 
| join [ fetch dt.davis.events
         | filter arrayIndexOf(affected_entity_types,"dt.entity.service") > -1
         | filter event.status != "CLOSED"
         | expand affected_entity_ids
         | fieldsKeep event.status, affected_entity_ids
         | summarize affected_entity_id=takeFirst(affected_entity_ids), by: {event.status, affected_entity_ids}
       ],
       kind:leftOuter,
       on: left[id] == right[affected_entity_id]
| fieldsAdd health=if(isNull(right.event.status),"OK",else: "NOT OK")
| fieldsRename service=entity.name
| fieldsKeep service,id,health
| sort service asc

 

 

Certified Dynatrace Master, Dynatrace Partner - 360Performance.net

samgar-kali
Dynatrace Enthusiast
Dynatrace Enthusiast

Running operations in DQL with several metrics

samgarkali_0-1725985511937.png

timeseries {
  {used=avg(dt.host.memory.used)},
  {available=avg(dt.host.memory.avail.bytes)}
}, by:{dt.entity.host}
| fieldsAdd total = (used[] + available[])
| fieldsAdd used_percentage = (used[] / total[] * 100)
| fieldsRemove used, available, total



 

 

 

marco_irmer
Champion

Split timeseries data into one record per interval (useful for data export)

Metric data sometimes needs to be displayed as one row per time interval for use in tables or for export to other systems. Dynatrace's native format for timeseries events can complicate this process because the data values for the entire timeframe of a given timeseries are represented as an array within a single record.

marco_irmer_0-1740177574203.png

We can overcome this challenge by using an iterative expression and applying some transformations to generate a separate record for each discrete interval. This data can then be shown in table format, or exported to CSV, where each row contains a single interval and its data value(s).

DQL Query:

 

timeseries value = sum(dt.service.request.count), interval: 1h

// *** timeseries interval splitter start ***
| fields  interval=record(
          timeframe.start = timeframe[start] + interval * iIndex(),
          value[]
          /* add any dimension split (by:) field names here */
          )
| expand interval
| fieldsFlatten interval
| fieldsRemove interval
// *** timeseries interval splitter end ***

 

 

Query Output:marco_irmer_1-1740177978262.png

 

Kenny_Gillette
DynaMight Leader
DynaMight Leader

DQL Builder & Validator dashboard

https://community.dynatrace.com/t5/Dynatrace-tips/Pro-Tip-with-DQL-quot-DQL-Builder-amp-Validator-da...

Team,

Please see this great DQL dashboard that was created by Dynatrace (everyone can download!).  Glad I checked Linkedin.

https://www.linkedin.com/posts/imrankhan4z_dynatrace-grail-dql-activity-7298017012411232257-j2bH/?ut...

 

Hello Dynatrace universe! Sharing another tool to help you get started with hashtag#Dynatrace hashtag#GRAIL. With this DQL Builder & Validator dashboard (https://lnkd.in/eXNtxT4A) you can easily search for any available data objects (entities, cloud, logs, spans, problems, etc.) and have a standard hashtag#DQL ready with all available fields. If you would ask what fields are available for a data table in GRAIL, you can easily find that list or pick certain fields that you need. There's also a custom DQL validator to check if the query is correct. Thanks to Sowmiya Venkiteswaran and Bradley Danyo for assisting with this dashboard! Grab your copy from Dynatrace Playground here, https://lnkd.in/eXNtxT4A

Dynatrace Certified Professional

Kenny_Gillette
DynaMight Leader
DynaMight Leader

How to pull in Management Zones via DQL

dql

fetch dt.entity.service
| filter isNotNull(managementZones)
| fields managementZones
| dedup managementZones

Dynatrace Certified Professional

Featured Posts