# PRO TIP - DQL for Query Usage Cost and Audit.

**URL:** <https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236>\
**Category:** Dynatrace Tips\
**Tags:** dql, tips-and-tricks, licensing\
**Created:** [February 22, 2024, 1:08am UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236 "2024-02-22T01:08:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dant3](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dant3/32/159_2.png) [@Dant3](https://community.dynatrace.com/u/Dant3)\
**Post date:** [February 22, 2024, 1:08am UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/1 "2024-02-22T01:08:22Z")

</div>

So, I&nbsp; assumed that something like this might be already posted. But since I couldn’t find it I will just drop it here, just in case.

So with the new and shiny DQL and GA of DPS moving forward, we need a way to “Have a glance” at what the hell the users are querying. I expect that the lovely “Consumption” gets back for DPS at some point. But while we wait let’s fix it with a Query lol.

So these two use cases have the same basic query:

```markup
fetch dt.system.events
| filter matchesValue(event.kind, "QUERY_EXECUTION_EVENT")
| sort timestamp DESC

```

So for those that do not know, there are a bunch of buckets with system info… cool info.

But with the event kind “QUERY\_EXECUTION\_EVENT” you get those juicy executed queries, doing a little math you can get (based on the default rate card) how much GB and $$$ are being dropped in those queries:

```markup
fetch dt.system.events
| filter matchesValue(event.kind, "QUERY_EXECUTION_EVENT")
| fieldsAdd consumidoGiB = ((scanned_bytes) * 0.000000000931322574615478515625) 
| fieldsAdd consumidoGiBCosto = consumidoGiB * 0.00365 
| fieldsKeep timestamp, consumidoGiBCosto, consumidoGiB, scanned_bytes, analysis_timeframe.start, analysis_timeframe.end, client.application_context, query_string, user, user.email
| summarize Cost = sum(consumidoGiBCosto), by:{user.email}
| sort Cost desc

```

Look to those Juicy USD spent in queries!

 ![Dant3_1-1708562455218.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/f/2f404eb8ca0b8a4c80d83433ba657eaef162caa5.png)

And from where?

 ![Dant3_0-1708564004825.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/b/5bf7d163273e6e2c66f97ecc215fa603710b101c.png)

Anyhow.. this consumes too.. but so far I have only seen consumptions of maybe 11 MiB scanned, for 30 days in a “big” environment. So is cheap (IMO)

Now.. one could also do something similar for those buckets that ARE important… you know, the one that might have PII stuff maybe.

```markup
fetch dt.system.events
| filter matchesValue(event.kind, "QUERY_EXECUTION_EVENT")
| fieldskeep timestamp, bucket, delivered_records, status, user, user.email, query_string
| sort timestamp DESC

```

It is pretty much a simple query, the result is self-explanatory.

 ![Dant3_2-1708563357232.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/6/d6f1cec0f3f0fb911745b8596a1e917106a5ec4e.png)

So, anyway hope you guys find it useful to track down those users who might consume… a little too much or maybe those apps and automations that have a high cost!

Cheers

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [February 27, 2024, 9:31pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/2 "2024-02-27T21:31:23Z")

</div>

Great, thanks [@Dant3](https://community.dynatrace.com/user/21769)

---

<div class="post-metadata">

**Author:** ![cesarsaravia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/cesarsaravia/32/12818_2.png) [@cesarsaravia](https://community.dynatrace.com/u/cesarsaravia)\
**Post date:** [February 27, 2024, 10:24pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/3 "2024-02-27T22:24:01Z")

</div>

Amazing tip&nbsp;[@Dant3](https://community.dynatrace.com/user/21769),&nbsp;thanks for sharing!

---

<div class="post-metadata">

**Author:** ![sujit\_k\_singh](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sujit\_k\_singh](https://community.dynatrace.com/u/sujit_k_singh)\
**Post date:** [March 13, 2024, 5:18am UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/4 "2024-03-13T05:18:58Z")

</div>

Thats interesting. Thanks&nbsp;[@Dant3](https://community.dynatrace.com/user/21769)&nbsp;for sharing this.

---

<div class="post-metadata">

**Author:** ![Marcelo\_santand](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marcelo_santand/32/13828_2.png) [@Marcelo\_santand](https://community.dynatrace.com/u/Marcelo_santand)\
**Post date:** [March 18, 2024, 12:38pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/5 "2024-03-18T12:38:19Z")

</div>

Thats interesting. Thanks

---

<div class="post-metadata">

**Author:** ![Sajarra](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Sajarra](https://community.dynatrace.com/u/Sajarra)\
**Post date:** [March 10, 2025, 3:09pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/6 "2025-03-10T15:09:28Z")

</div>

Great Info. BTW, is that possible to find the events in GB for each management zones (total number of events (in GB) in each MZs)? I will give a rough idea, how much it will cost if we are querying it.

---

<div class="post-metadata">

**Author:** ![dwarakanath](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dwarakanath](https://community.dynatrace.com/u/dwarakanath)\
**Post date:** [October 1, 2025, 8:30pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/7 "2025-10-01T20:30:51Z")

</div>

Hi&nbsp;[@Dant3](https://community.dynatrace.com/user/21769)&nbsp;  
We’ve noticed a billing increase over the last two weeks in our Dynatrace account, and we would like to understand the root cause. Specifically, we want to:

1. Identify which events, usage types, or capabilities are contributing to the increased costs.
2. Understand whether old Davis AI-based detections, which were set to inactive in July, could be related, since currently the Davis AI option appears disabled for all dashboard charts.
3. Get guidance on how to query or extract detailed billing and usage data that can help us pinpoint the high-cost events.

Could you please provide a DQL query or approach that would allow us to see:

- Capability name
- Environment
- Entity (host, service, workflow, or log source)
- Usage type
- Usage volume
- Cost in USD
- Timestamp

…and any other details that would help us fully understand the billing increase?

This will help us take steps to optimize and reduce costs effectively.

 ![image (16).png](https://global.discourse-cdn.com/dynatrace/original/3X/b/2/b2e91e05fe2c39571bbe8f26d7e877f1310a1d0f.png)

---

<div class="post-metadata">

**Author:** ![AlexLarrieu](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@AlexLarrieu](https://community.dynatrace.com/u/AlexLarrieu)\
**Post date:** [October 16, 2025, 3:42pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/8 "2025-10-16T15:42:25Z")

</div>

I am interested in the answer to this question.

---

<div class="post-metadata">

**Author:** ![Scott\_McMahon](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/scott_mcmahon/32/36865_2.png) [@Scott\_McMahon](https://community.dynatrace.com/u/Scott_McMahon)\
**Post date:** [February 6, 2026, 3:57pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/9 "2026-02-06T15:57:05Z")

</div>

Very useful thanks

---

<div class="post-metadata">

**Author:** ![kingstar17](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kingstar17](https://community.dynatrace.com/u/kingstar17)\
**Post date:** [April 7, 2026, 1:42pm UTC](https://community.dynatrace.com/t/pro-tip-dql-for-query-usage-cost-and-audit/44236/10 "2026-04-07T13:42:56Z")

</div>

Amazing, Thanks&nbsp;[@Dant3](https://community.dynatrace.com/user/21769)&nbsp;- Is it possible to view the raw query instead of \*? This will be helpful to view the exact unmasked query strings.
