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!

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!