cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the total number of queries run per day on a databricks SQL warehouse/endpoint?

207474
New Contributor
3 REPLIES 3

AmanSehgal
Honored Contributor III

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.

Thank you, you saved my job. 

Vidula
Honored Contributor

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!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.