如何获取azure databricks笔记本运行详细信息

3mpgtkmj  于 2021-05-24  发布在  Spark
关注(0)|答案(2)|浏览(455)

我正在使用azure数据工厂运行我的databricks笔记本,它在运行时创建作业集群,现在我想知道这些作业的状态,我的意思是它们是成功的还是失败的。那么,我可以知道,如何通过使用作业id或运行id来获取运行状态。
注意:我还没有在我的databricks工作区中创建任何作业,我正在使用azure数据工厂运行我的笔记本,它在运行时创建了作业群集,并在该群集上运行该笔记本,然后终止该群集

kq4fsx7k

kq4fsx7k1#

您必须转到azure数据工厂中的监视器页面。您可以在这里按runid进行筛选。
https://docs.microsoft.com/en-us/azure/data-factory/transform-data-using-databricks-notebook#monitor-管道运行

s3fp2yjn

s3fp2yjn2#

import json
import requests

gethooks= "https://" + databricks_instance_name + "/api/2.0/jobs/runs/list"     #add your databricks workspace instance name over here
headers={"Authorization": "Bearer********************"}        # Add your databricks access token
response = requests.get(gethooks, headers=headers)

print(response.json())      # you will get all cluster and job related info over here in json format

# traversing through response.json

for element in response.json()['runs']:
    job_id = element['job_id']
    status = element['state']['result_state']
    job_path = element['task']['notebook_task']['notebook_path']
    job_name = job_path.split('/')

相关问题