# DQL Fetch Logs Averages

**URL:** <https://community.dynatrace.com/t/dql-fetch-logs-averages/47384>\
**Category:** DQL\
**Tags:** dql\
**Created:** [August 29, 2024, 1:58pm UTC](https://community.dynatrace.com/t/dql-fetch-logs-averages/47384 "2024-08-29T13:58:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gib80](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@Gib80](https://community.dynatrace.com/u/Gib80)\
**Post date:** [August 29, 2024, 1:58pm UTC](https://community.dynatrace.com/t/dql-fetch-logs-averages/47384/1 "2024-08-29T13:58:13Z")

</div>

Hi All,

I am currently trying to write some dql which will provide some graphical data from the fetch logs command.

This is the fetch logs command I have so far below.&nbsp; I need to average the results by 1day and 7days, whist also showing the status code field

fetch logs  
| filter application ==“myapp” or application == “mayapp2”  
| filter sourcecontext == “source”  
| filter requestpath == “limits/daily”

| summarize count(), by:{statuscode}

Is this possible?

Thanks

---

<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:** [August 30, 2024, 8:57pm UTC](https://community.dynatrace.com/t/dql-fetch-logs-averages/47384/2 "2024-08-30T20:57:18Z")

</div>

If I understand the need correctly, first you need to calculate counts per day. This can be done this way:

```markup
fetch logs
| summarize cnt=count(), by:{status, timestamp=bin(timestamp,1d,at:-2h) }

```

 ![krzysztof_hoja_0-1725051122575.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/0/a0bdba03b2e38d0264ba8638eba6dd7946afc96d.png)

In the next step you need to average daily counts:

```markup
fetch logs
| summarize cnt=count(), by:{status, timestamp=bin(timestamp,1d,at:-2h) }
| summarize cnt=avg(cnt), by: {status}

```

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

notes: I used column _status_, I do not have _stauscode ;_&nbsp;I used _ **samplingRatio** _ parameter in my queries to speed up their execution
