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 to get the last time ( previous ) databricks job run time?

sgannavaram
New Contributor III

How to get the last databricks job run time? I have a requirement where i need to pass last job runtime as an argument in SQL and this SQL get the records from snowflake database based on this timestamp.  

1 ACCEPTED SOLUTION

Accepted Solutions

Hubert-Dudek
Esteemed Contributor III
6 REPLIES 6

Hubert-Dudek
Esteemed Contributor III

sgannavaram
New Contributor III

Thank you very much for your response Hubert. How can we call these api in databricks code? it would be really help if you have any sample code.

RKNutalapati
Valued Contributor

@Srinivas Gannavaramโ€‹ : Sample python pseudocode for jobs API. Hope this helps you to build your Logic

import requests
import json
 
databricks_instance ="<databricks-instances>"
url_list = f"{databricks_instance}/api/2.1/jobs/runs/get?run_id=<Your Job RunID>"
 
headers = {
 'Authorization': 'Bearer <databricks-access-token>',
 'Content-Type': 'application/json'
}
 
response = requests.request("GET", url_list, headers=headers).json()
print(response)
print(response['job_id'])
print(response['start_time'])
print(response['end_time'])

Thank you so much. I will test it.

Anonymous
Not applicable

@Srinivas Gannavaramโ€‹ - Please let us know how it goes!

Anonymous
Not applicable

Hey there @Srinivas Gannavaramโ€‹ 

Hope you are well. Just wanted to see if you were able to find an answer to your question and would you like to mark an answer as best? It would be really helpful for the other members.

Cheers!

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