You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by va...@gmail.com, va...@gmail.com on 2018/05/28 12:48:21 UTC

Alert Emails Templatizing

Hi team,

We had a use case where we wanted to serve different email body to different use cases at the time of failure & up_for_retry, currently body seems to be hard coded in models.py, Is there any plan to make it templatized in upcoming future or it will be a good idea if we come across with code change and contribute? Please suggest recommended way of implementing the feature.


Regards,
Vardan Gupta

Re: Alert Emails Templatizing

Posted by va...@gmail.com, va...@gmail.com.
Thanks Ananth for explaining in well mannered order, that seems to be quite good idea but I doubt that will lead to code changes in existing code and would become backward compatible with latest releases, would that be good idea to wait for this PR: https://github.com/apache/incubator-airflow/pull/2338/files

On 2018/05/28 20:47:25, Ananth Durai <va...@gmail.com> wrote: 
> It is a bit tricky;
> *Step 1:*
> you can write an SLA miss callback, send email from the callback and empty
> the `slas` object so that airflow won't sent SLA miss email.
> https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L688
> 
> *Step 2:*
> You can reuse airflow `send_email` method here
> https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L61
> 
> *Step 3:*
> If you are sending sla_miss from your callback, you need to mutate the
> `sla_miss` table just like
> https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L726
> 
> I hope this will get simplified in the future releases.
> 
> Regards,
> Ananth.P,
> 
> 
> 
> 
> 
> 
> On 28 May 2018 at 05:48, vardanguptacse@gmail.com <va...@gmail.com>
> wrote:
> 
> > Hi team,
> >
> > We had a use case where we wanted to serve different email body to
> > different use cases at the time of failure & up_for_retry, currently body
> > seems to be hard coded in models.py, Is there any plan to make it
> > templatized in upcoming future or it will be a good idea if we come across
> > with code change and contribute? Please suggest recommended way of
> > implementing the feature.
> >
> >
> > Regards,
> > Vardan Gupta
> >
> 

Re: Alert Emails Templatizing

Posted by Ananth Durai <va...@gmail.com>.
It is a bit tricky;
*Step 1:*
you can write an SLA miss callback, send email from the callback and empty
the `slas` object so that airflow won't sent SLA miss email.
https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L688

*Step 2:*
You can reuse airflow `send_email` method here
https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L61

*Step 3:*
If you are sending sla_miss from your callback, you need to mutate the
`sla_miss` table just like
https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L726

I hope this will get simplified in the future releases.

Regards,
Ananth.P,






On 28 May 2018 at 05:48, vardanguptacse@gmail.com <va...@gmail.com>
wrote:

> Hi team,
>
> We had a use case where we wanted to serve different email body to
> different use cases at the time of failure & up_for_retry, currently body
> seems to be hard coded in models.py, Is there any plan to make it
> templatized in upcoming future or it will be a good idea if we come across
> with code change and contribute? Please suggest recommended way of
> implementing the feature.
>
>
> Regards,
> Vardan Gupta
>