Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Send email from Oozie Kill section

Solved Go to solution

Send email from Oozie Kill section

Rising Star

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Send email from Oozie Kill section

Expert Contributor

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>

4 REPLIES 4

Re: Send email from Oozie Kill section

Expert Contributor

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>

Re: Send email from Oozie Kill section

Rising Star
Thanks, that does the trick!

Re: Send email from Oozie Kill section

New Contributor

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.

Re: Send email from Oozie Kill section

New Contributor

this workflow is working? Just workflow and it will send to email?

Don't have an account?
Coming from Hortonworks? Activate your account here