cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
6 REPLIES 6

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!

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.