aws-databricks - databricks 笔记本读取 databricks 作业统计信息并将其写入雪花表
问题描述
我在数据块中安排了几项工作,其中我有兴趣阅读两个特定工作的统计信息。我需要编写一个 databricks 笔记本代码来将作业统计信息(jobName、startTime、endTime 和状态)写入雪花表。
解决方案
We can use following python code to get the details from databricks job api.
Note : tested code here
from pyspark.sql.types import IntegerType
from pyspark.sql.types import *
from pyspark.sql import Row
import base64
import requests
import json
databricks_instance ="<databricks-instances>"
url_list = f"{databricks_instance}/api/2.0/jobs/runs/get?run_id=39347"
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'])
推荐阅读
- php - CS-Cart:显示商店关闭屏幕
- c++ - 为什么我的类工作正常,即使返回垃圾值作为赋值运算符和空复制构造函数的返回?
- android - 颤振运行命令不会在 iOS 模拟器中启动
- javascript - 在 setInterval 中使用“this”的变量
- javascript - PHP调用Javascript函数不接受参数
- laravel - 如何通过 laravel 集合从数组中获取属性?
- css - 项目符号点文本 - 换行到 div 中的下一行
- javascript - VueX:等到商店数据被加载
- r - scale_fill_manual() 不会改变图例的颜色?
- php - Laravel 5 - 将变量传递给关系模型