Commit e87ab41a authored by 김진영's avatar 김진영
Browse files

Update batch_test.py

parent 1ce3e7dd
...@@ -4,6 +4,7 @@ import pendulum ...@@ -4,6 +4,7 @@ import pendulum
from airflow.operators.bash import BashOperator from airflow.operators.bash import BashOperator
from airflow import DAG from airflow import DAG
from data.gasan_data import gasanData # import cj-gasan data from data.gasan_data import gasanData # import cj-gasan data
from dateutil.relativedelta import relativedelta
# set timezone # set timezone
local_tz = pendulum.timezone("Asia/Seoul") local_tz = pendulum.timezone("Asia/Seoul")
...@@ -19,19 +20,26 @@ def fail_alert(context): ...@@ -19,19 +20,26 @@ def fail_alert(context):
"sections": [ "sections": [
{ {
"facts":[ "facts":[
{"name":"■ Execution Time", "value": "%s"}, {"name":"■ Exec Time", "value": "%s"},
{"name":"■ Task", "value": "%s"}, {"name":"■ Task", "value": "%s"},
{"name":"■ DAG", "value": "%s"}, {"name":"■ DAG", "value": "%s"},
{"name":"■ Log Path", "value": "%s"},
{"name":"■ Reason", "value": "%s"},
] ]
} }
] ]
} }
""" % (context.get('execution_date'), context.get('task_instance').task_id, context.get('task_instance').dag_id) """ % (
context.get('execution_date')+relativedelta(hours=9),
context.get('task_instance').task_id,
context.get('task_instance').dag_id,
context.get('task_instance').log_url,
context.get('exception')
)
alert = BashOperator( alert = BashOperator(
task_id='fail_alert', task_id='fail_alert',
bash_command="curl -d \'{data}\' -H \"Content-Type: Application/JSON\" -X POST https://lottegroup.webhook.office.com/webhookb2/2ed9f7fc-4c60-4d2d-a61c-aa50c0075564@dc742f86-8941-4de1-8d2c-d2dfef93cfe8/IncomingWebhook/1047eeaf7bde45a08e5ccb4d6c80f08d/d7352368-8126-4827-aab7-4a62b0b5abc2".format(data=context_data) bash_command="curl -d \'{data}\' -H \"Content-Type: Application/JSON\" -X POST https://lottegroup.webhook.office.com/webhookb2/2ed9f7fc-4c60-4d2d-a61c-aa50c0075564@dc742f86-8941-4de1-8d2c-d2dfef93cfe8/IncomingWebhook/1047eeaf7bde45a08e5ccb4d6c80f08d/d7352368-8126-4827-aab7-4a62b0b5abc2".format(data=context_data)
# bash_command="curl -d \'{\"@context\":\"https://schema.org/extensions\",\"@type\":\"MessageCard\",\"themeColor\":\"0072C6\",\"title\":\"Batch Job Error\",\"summary\":\"test\",\"sections\":[{\"facts\":[{\"name\":\"TEST1\", \"value\": \"TEST1\"}]}]}\' -H \"Content-Type: Application/JSON\" -X POST https://lottegroup.webhook.office.com/webhookb2/2ed9f7fc-4c60-4d2d-a61c-aa50c0075564@dc742f86-8941-4de1-8d2c-d2dfef93cfe8/IncomingWebhook/1047eeaf7bde45a08e5ccb4d6c80f08d/d7352368-8126-4827-aab7-4a62b0b5abc2"
) )
return alert.execute(context=context) return alert.execute(context=context)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment