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!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group