# API, Database Statement Response Time by Request Count

**URL:** <https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177>\
**Category:** Open Q&A\
**Tags:** databases, dynatrace-api\
**Created:** [November 8, 2022, 12:56am UTC](https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177 "2022-11-08T00:56:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TylerProduct](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@TylerProduct](https://community.dynatrace.com/u/TylerProduct)\
**Post date:** [November 8, 2022, 12:56am UTC](https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177/1 "2022-11-08T00:56:33Z")

</div>

Hello, I’m trying to hit an API that will return the response time of my top X database statements by response time. Im using the accept:text/csv header, and would like to see the response time and request count returned in separate columns for each X database statement for a given a period of time.

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [November 10, 2022, 11:50am UTC](https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177/2 "2022-11-10T11:50:05Z")

</div>

Hi, you can combine boths calls in a single API call but it won’t output a single array with two dimensions. You have to process them afterwards.

see example:

/api/v2/metrics/query?metricSelector=(builtin:service.response.time:splitBy():sort(value(auto,descending)):limit(100)):limit(100):names,(builtin:service.requestCount.total:splitBy():sort(value(auto,descending)):limit(100)):limit(100):names&from=-2h&to=now&api-token=XXXXXXXXXXXXX

---

<div class="post-metadata">

**Author:** ![TylerProduct](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@TylerProduct](https://community.dynatrace.com/u/TylerProduct)\
**Post date:** [November 10, 2022, 1:24pm UTC](https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177/3 "2022-11-10T13:24:57Z")

</div>

Thank you for your reply, this is very helpful. How do I add the database statements do the call so I can map them to the values?

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [November 10, 2022, 1:45pm UTC](https://community.dynatrace.com/t/api-database-statement-response-time-by-request-count/37177/4 "2022-11-10T13:45:02Z")

</div>

Database statements metrics are not available out of the box for each statement. It’s the same as for webservice request/operation at webservice level.  
Statements must be marked as key requests before (see below)

 ![dbkr.jpg](https://global.discourse-cdn.com/dynatrace/original/3X/9/9/990422c5302067fb54e11e42f3656edc8ea73fb8.jpeg)

Then the related metrics that you can use are

builtin:service.keyRequest.count.total for request count

builtin:service.keyRequest.response.time for response time

you can filter by key request identifier which is “SERVICE\_METHOD-XXXXXXX” you can find in the url of the screenshot above.
