# Filter Time-Series Data Points by Value Threshold Using DQL

**URL:** <https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed\
**Created:** [February 11, 2025, 4:11pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209 "2025-02-11T16:11:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jegron](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jegron/32/12797_2.png) [@jegron](https://community.dynatrace.com/u/jegron)\
**Post date:** [February 11, 2025, 4:11pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/1 "2025-02-11T16:11:24Z")

</div>

Hi!

I have a values-type metric. I’d like to display a timeseries that only counts datapoints whose value is greater than (or less than) an arbitrary value.&nbsp;I don’t want to filter an aggregation, but analyze each value and remove the ones I don’t want.

How can I achieve this?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [February 13, 2025, 7:53am UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/2 "2025-02-13T07:53:07Z")

</div>

I am not sure if I got the requirement correctly. Here are my thought:

To get timeseries (cpu usage in my example) where at least one value is greater the predefined threshold _ **iAny** _ function can help

```markup
timeseries cpu=avg(dt.host.cpu.usage), by: {dt.entity.host}
| filter iAny(cpu[]>80)

```

 ![krzysztof_hoja_0-1739432891493.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/c/cc76664a08a08be151f7d594a6e4d17931549a95.png)

and to see in the final result only datapoint matching this conditions “iterative expression” is useful:

```markup
timeseries cpu=avg(dt.host.cpu.usage), by: {dt.entity.host}
| filter iAny(cpu[]>80)
| fieldsAdd cpu = if(cpu[]>80, cpu[])

```

 ![krzysztof_hoja_1-1739433046090.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/a/4ae9c4b63dd76625d0a02869c3e40fbebcb331c3.png)

---

<div class="post-metadata">

**Author:** ![jegron](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jegron/32/12797_2.png) [@jegron](https://community.dynatrace.com/u/jegron)\
**Post date:** [February 17, 2025, 4:09pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/3 "2025-02-17T16:09:36Z")

</div>

Hi&nbsp;[@krzysztof\_hoja](https://community.dynatrace.com/user/25373)&nbsp;!

Thanks for your help.&nbsp;But you are filtering the result of avg(dt.host.cpu.usage). I would like to filter each data point independently before any aggregation. I would like to build response time SLO for example 🙂 I can do it easily with fetch logs but I can’t find a solution with the timeseries command …

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [February 18, 2025, 8:43pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/4 "2025-02-18T20:43:24Z")

</div>

You cannot find it, because it does not exists in generic case for timeseries 🙂

I used&nbsp;dt.host.cpu.usage with breakdown by host sort of on purpose. Let’s consider this query:

```markup
timeseries { cpu=avg(dt.host.cpu.usage), cpu_t=sum(dt.host.cpu.usage, rollup:total) } , by: {dt.entity.ec2_instance, dt.entity.host}
| filter dt.entity.host == "HOST-937E3C790B64E8B5"

```

Besides plain average I added second timeseries: sum with rollup:total. This additional metric will tell us how many contributions aka raw measurement happened. Result looks like this:

 ![krzysztof_hoja_0-1739910114535.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/e/8eee665da06166711bce29fc81c8f22fe489921a.png)

The value of cpu\_t is constantly 6 every minute because reading of cpu usage for host happens every 10 sec. But this individual measurement are not stored. What is stored and is in fact most granular “data point” is statistical description of what happened containing in basic case 4 values: min, max, sum and count (sum and count allows to calculate average). From this compounds bigger aggregates can be calculated like for host groups or for longer intervals.

If we take a look at similar query:

```markup
timeseries { rt=avg(dt.service.request.response_time), rt_t=sum(dt.service.request.response_time, rollup:total) } , by: {dt.entity.service}
, filter: dt.entity.service == "SERVICE-CB0AFF6C5BC4EABE"

```

and result

 ![krzysztof_hoja_0-1739910740305.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/f/af4a2f48608919a8741a431b7a4579527ffb74a6.png)

you can see that number of contributions is variable: these are actuals requests. But this metrics has also additional dimension which can allow to look at it at more granular way. Adding “endpoint.name” allows to look at this at more granular way:

 ![krzysztof_hoja_1-1739910948875.png](https://global.discourse-cdn.com/dynatrace/original/2X/a/a8ee73da8353bf0a08529cba910624cd94b5d28c.png)

You can even look deeper by splitting requests into successful and failed, but in generic case you will get to the point when you get datapoint representing single requests. You may just have it by chance when only one request fell in the specific bucket.

The basic idea of metric is to have aggregated view on a process (bucketized time, selected dimensions only) - you loos details but you gain easy and fast access. If details are needed: for some cases we have span&nbsp; to look deeper (service.request.response\_time can be recreated from spans if no sampling occurs), but also for some we do not keep details.

---

<div class="post-metadata">

**Author:** ![jegron](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jegron/32/12797_2.png) [@jegron](https://community.dynatrace.com/u/jegron)\
**Post date:** [March 20, 2025, 3:24pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/5 "2025-03-20T15:24:26Z")

</div>

Hi&nbsp;[@krzysztof\_hoja](https://community.dynatrace.com/user/25373)&nbsp;! Thanks for explanation. Is there a roadmap to implement filtering on raw datapoints, even if it results in slower performance?

---

<div class="post-metadata">

**Author:** ![jegron](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jegron/32/12797_2.png) [@jegron](https://community.dynatrace.com/u/jegron)\
**Post date:** [May 14, 2025, 9:13am UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/6 "2025-05-14T09:13:33Z")

</div>

Hi&nbsp;[@krzysztof\_hoja](https://community.dynatrace.com/user/25373)&nbsp;!

This is still an ongoing issue for us. Due to the high cost of handling a large volume of logs, we rely primarily on metrics. However, Dynatrace SLOs suffer from a lack of precision caused by data aggregation. Our customer is comparing our new Dynatrace SLOs with their legacy SLOs from Splunk, which are based on raw log data, and the results are not consistent (i.e., not idempotent).

Is there anything new planned on your side to address this issue?

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [May 14, 2025, 2:54pm UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/7 "2025-05-14T14:54:29Z")

</div>

What’s the actual definition of SLO?

---

<div class="post-metadata">

**Author:** ![J01am](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@J01am](https://community.dynatrace.com/u/J01am)\
**Post date:** [May 15, 2025, 8:21am UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/8 "2025-05-15T08:21:29Z")

</div>

Hi&nbsp;[@krzysztof\_hoja](https://community.dynatrace.com/user/25373)

Currently, on Splunk, SLO are definied based on the ratio of response time that is under a threshold.

That is somethink like :

index = my\_app duration\>0  
| eval threshold = 0.5  
| eval count\_under\_threshold = if(duration \< threshold, 1, 0)

| timechart sum(count\_under\_threshold) as count\_under\_threshold, count(duration) as&nbsp;count\_all span=1d

| eval sli = 100\*count\_under\_threshold/count\_all

So, each duration is analyzed.

In Dynatrace and Timeseries, we need to firstly agregate duration into avg/max/min with 1m resolution, and then compare it to the threshold.

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [May 19, 2025, 6:48am UTC](https://community.dynatrace.com/t/filter-time-series-data-points-by-value-threshold-using-dql/50209/9 "2025-05-19T06:48:33Z")

</div>

Ok, so it it for specific set of requests…

Please consider creating two metric for this purpose: count of all spans/request and count of “slow” spans/requests.&nbsp;  
Alternatively you can use built in metric (dt.service.request.count) if it can act ad denominator (has right content and/or all needed dimensions to extract subset you need)
