cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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!

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!