# Output of total number of http errors using DQL

**URL:** <https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963>\
**Category:** DQL\
**Tags:** dql\
**Created:** [September 25, 2024, 6:27am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963 "2024-09-25T06:27:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taihei](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Taihei](https://community.dynatrace.com/u/Taihei)\
**Post date:** [September 25, 2024, 6:27am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/1 "2024-09-25T06:27:08Z")

</div>

Please tell me how to output the total “reqcount” value in the following DQL.

timeseries reqcount=sum(dt.service.request.count, default:0),  
by:{http.response.status\_code},  
filter:{  
dt.entity.service == “XXXXXXX”  
and http.response.status\_code == 500  
}

---

<div class="post-metadata">

**Author:** ![andreas\_grabner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/andreas_grabner/32/27879_2.png) [@andreas\_grabner](https://community.dynatrace.com/u/andreas_grabner)\
**Post date:** [September 25, 2024, 6:34am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/2 "2024-09-25T06:34:24Z")

</div>

Hi

Have a look at this dashboard on the Playground TEnant - you get a couple of great DQL query examples for e.g: Failure Rate but it also shows some filter options in dashboards:&nbsp;[Dynatrace](https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.dashboards/dashboard/29f7a7c0-6c4c-4f02-9a71-a1f327273e51)

---

<div class="post-metadata">

**Author:** ![andreas\_grabner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/andreas_grabner/32/27879_2.png) [@andreas\_grabner](https://community.dynatrace.com/u/andreas_grabner)\
**Post date:** [September 25, 2024, 6:37am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/3 "2024-09-25T06:37:14Z")

</div>

And to your question. You could use the new Metrics Tile in the Dashboard and easily create that DQL simply through point and click and then also see the DQL

 ![andreas_grabner_0-1727246224652.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e8c7d15e21dc567fca000da7f303e6302e2e648d.png)

---

<div class="post-metadata">

**Author:** ![Taihei](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Taihei](https://community.dynatrace.com/u/Taihei)\
**Post date:** [September 25, 2024, 7:28am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/4 "2024-09-25T07:28:18Z")

</div>

Thank you for your help!  
I was able to output the total “reqcount” value.

Please tell us the following in addition.

How do I write a DQL statement that returns 0 if there are no records?

I could not write the following, but it’s not working.

timeseries reqcount=sum(dt.service.request.count, default:0) ,  
by:{http.response.status\_code},  
filter:{  
dt.entity.service == “XXXXXXXXXXXXXXX”  
and http.response.status\_code == 500  
}  
| fieldsAdd result=if(arraySum(reqcount) \> 0, arraySum(reqcount), else: 0)

---

<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:** [September 25, 2024, 3:02pm UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/5 "2024-09-25T15:02:03Z")

</div>

You can use&nbsp;_ **nonempty:true** _ parameter for _ **timeseries** _ command to ensure that it always returns something

---

<div class="post-metadata">

**Author:** ![Taihei](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Taihei](https://community.dynatrace.com/u/Taihei)\
**Post date:** [September 26, 2024, 12:51am UTC](https://community.dynatrace.com/t/output-of-total-number-of-http-errors-using-dql/47963/6 "2024-09-26T00:51:10Z")

</div>

Resolved. Thank you very much.

I have created a DQL as follows

timeseries reqcount=sum(dt.service.request.count, default:0) ,  
nonempty:true,  
by:{http.response.status\_code},  
filter:{  
dt.entity.service == “XXXXXXXXXXXXXXX”  
and http.response.status\_code == 500  
}  
| fieldsAdd result=if(arraySum(reqcount) \> 0, arraySum(reqcount), else: 0)
