通過yarn timeline server api查詢tez任務(wù)的運行數(shù)據(jù)

這里面最坑爹的就是tez記錄在timelineserver中的entity_type值:TEZ_DAG_ID
timelineserver并沒有接口查詢所有的entity_type
這個原因主要是因為timelineserver使用了levelDB作為序列化存儲:https://zh.wikipedia.org/wiki/LevelDB

另外參考:
timelineserver的api文檔:http://han-zw.iteye.com/blog/2332924

import json
import requests

parameter = {'limit': '11',
             '_': '1533712088094'
             }
ambari_user = 'admin'
ambari_pass = 'admin'
response = requests.get('http://{yarn-timelineserver-host}:8188/ws/v1/timeline/TEZ_DAG_ID', parameter)

json_data = response.json()
entities_ = json_data['entities']

entity = entities_[0]
otherinfo_ = entity['otherinfo']
res = {

    'domain_':entity['domain'],
    'dag_id':entity['entity'],

    'app_id':otherinfo_['applicationId'],
    'description_': otherinfo_['dagPlan']['dagContext']['description'],
    'user_':otherinfo_['user'],
    'time_taken_': otherinfo_['timeTaken'],
    'start_time_': otherinfo_['startTime'],
    'end_time_': otherinfo_['endTime'],
    'queue_name_': otherinfo_['queueName'],

}
for k, v in res.iteritems():
    print(k +'|' + str(v))
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容