Created on 03-14-2015 08:26 PM - edited 09-16-2022 02:24 AM
Hello,
I would like to send an email in case an oozie workflow fails, i.e. from the "kill" section of the workflow. Is this possible? The documentation I found on oozie website only mentions the "message" element which simply writes to a log.
https://oozie.apache.org/docs/4.0.0/WorkflowFunctionalSpec.html#a3.1.3_Kill_Control_Node
Thanks, Martin
Created 03-16-2015 06:12 AM
Hey,
You can't have a kill action send an email. However, you can have your other actions change their kill to be an email action that sends the email and then the email action goes to a kill. Like:
<workflow-app name="shell-wf" xmlns="uri:oozie:workflow:0.4">
<start to="shell"/>
<action name="shell">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>shell.sh</exec>
<file>shell.sh#shell.sh</file>
</shell>
<ok to="end"/>
<error to="kill-email"/>
</action>
<action name="kill-email">
<email xmlns="uri:oozie:email-action:0.1">
<to>cconner@test.com</to>
<cc>other-cconner@test.com</cc>
<subject>WF ${wf:id()} failed</subject>
<body>Shell action failed.</body>
</email>
<ok to="kill"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
Created 03-16-2015 06:12 AM
Hey,
You can't have a kill action send an email. However, you can have your other actions change their kill to be an email action that sends the email and then the email action goes to a kill. Like:
<workflow-app name="shell-wf" xmlns="uri:oozie:workflow:0.4">
<start to="shell"/>
<action name="shell">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>shell.sh</exec>
<file>shell.sh#shell.sh</file>
</shell>
<ok to="end"/>
<error to="kill-email"/>
</action>
<action name="kill-email">
<email xmlns="uri:oozie:email-action:0.1">
<to>cconner@test.com</to>
<cc>other-cconner@test.com</cc>
<subject>WF ${wf:id()} failed</subject>
<body>Shell action failed.</body>
</email>
<ok to="kill"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
Created 03-23-2015 03:47 AM
Created on 11-30-2017 03:22 AM - edited 11-30-2017 03:23 AM
How about rerun? If the oozie job fails during rerun this email action will not send email as this action is marked as SUCCESS during first run. How to kick email action during failure in rerun?
Thanks.
Created 04-12-2019 06:14 AM
this workflow is working? Just workflow and it will send to email?