Output of total number of http errors using DQL

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
}

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: Dynatrace

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

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)

You can use nonempty:true parameter for timeseries command to ensure that it always returns something

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)