How do I get the total number of queries run per day on a databricks SQL warehouse/endpoint?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 05:24 AM
I am trying to access the API:
GET https://<databricks-instance>.cloud.databricks.com/api/2.0/sql/history/queries
- Labels:
-
SQL Endpoint
-
Total
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 07:28 PM
Use the above API with HTTP security scheme type.
http://<db_worksapce>.cloud.databricks.com/api/2.0/sql/history/queries
Create a PAT Token in warehouse and use it for bearer token.
Say you want to generate your report for 13th July +0 UTC and 14th July +0 UTC.
Start time: Jul 13 2022 00:00:00 - start_time_ms: 1657720800000
End time: Jul 14 2022 00:00:00 - end_time_ms: 1657756800000
Your request will look like this:
{
"filter_by": {
"query_start_time_range": {
"end_time_ms": 1657756800000,
"start_time_ms": 1657720800000
},
"statuses":["FINISHED","FAILED"],
"warehouse_ids":
[
"<warehouse_id>"
]
},
"include_metrics": true,
"max_results": 100
}
In response from the API, the number of entries inside "res" is equal to number of queries run per day on your provided warehouse_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 03:10 AM - edited 08-08-2023 02:44 AM
Thank you, you saved my job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 03:17 AM
Hi there @Sravan Burla
Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.
We'd love to hear from you.
Thanks!

