优化
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from airflow import DAG
|
||||
from airflow.operators.python_operator import PythonOperator
|
||||
from datetime import datetime
|
||||
from airflow.hooks.http_hook import HttpHook
|
||||
import json
|
||||
from goojia_utils import dingutils
|
||||
|
||||
|
||||
|
||||
def send_dingding_alert(context):
|
||||
@@ -11,12 +11,7 @@ def send_dingding_alert(context):
|
||||
url = task_instance.log_url.replace("http://localhost:8080", "https://airflow.fangjia.com")
|
||||
message = f"[airflow]任务{task_instance.task_id}错误,请点击{url}查看!"
|
||||
print(message)
|
||||
http_hook = HttpHook(method="POST", http_conn_id="dingding_webhook")
|
||||
http_hook.run(
|
||||
endpoint="robot/send",
|
||||
data=message.encode('utf-8'),
|
||||
headers={"Content-Type": "application/json;charset=utf-8"}
|
||||
)
|
||||
dingutils.send_text(message, "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4")
|
||||
print("success")
|
||||
|
||||
def fail_task():
|
||||
|
||||
Reference in New Issue
Block a user