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.

Modifying the email subject in ambari alert

Solved Go to solution

Modifying the email subject in ambari alert

Expert Contributor

I have requirement to modify the email subject from Ambari for certain alerts. For example, anything related to HDFS, I need to have "CRITICAL HDFS" in the subject line. I went through this link : https://community.hortonworks.com/questions/198815/ambari-email-alert-format.html

but it does not talk about customizing the subject for certain alerts.

Has anyone has this setup in your environment ?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Modifying the email subject in ambari alert

Hi @Kumar Veerappan,

I guess you are referring to this blog for Customizing the Ambari Alert : https://cwiki.apache.org/confluence/display/AMBARI/Customizing+the+Alert+Template

then you can change the alert to Your desired one with help of editing the <subject></subject> in alert-templates.xml : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/alert-templates.xml#L21

Just for example, I have some changes on subject for my Business logic :

 <subject>
      <![CDATA[
     #set( $criticalServices = $summary.getServicesByAlertState("CRITICAL"))
     #if( $summary.getCriticalCount() ==0)
       There is no new critical Alert!
     #{else}
      We have $summary.getCriticalCount() Critical Alert(s).Alert Details : ,#foreach( $service in $criticalServices ) #foreach( $alert in $summary.getAlerts($service,"CRITICAL") ) Service Name : $alert.getServiceName(),Host Name : $alert.getHostName()
       #end
      #end
     #end 
       ]]>
    </subject>

Which is doing nothing but Listing critical alert count in the Email subject.

See if you can Makeuse of some thing out of it.

Please give a Accept answer if it did.

1 REPLY 1

Re: Modifying the email subject in ambari alert

Hi @Kumar Veerappan,

I guess you are referring to this blog for Customizing the Ambari Alert : https://cwiki.apache.org/confluence/display/AMBARI/Customizing+the+Alert+Template

then you can change the alert to Your desired one with help of editing the <subject></subject> in alert-templates.xml : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/alert-templates.xml#L21

Just for example, I have some changes on subject for my Business logic :

 <subject>
      <![CDATA[
     #set( $criticalServices = $summary.getServicesByAlertState("CRITICAL"))
     #if( $summary.getCriticalCount() ==0)
       There is no new critical Alert!
     #{else}
      We have $summary.getCriticalCount() Critical Alert(s).Alert Details : ,#foreach( $service in $criticalServices ) #foreach( $alert in $summary.getAlerts($service,"CRITICAL") ) Service Name : $alert.getServiceName(),Host Name : $alert.getHostName()
       #end
      #end
     #end 
       ]]>
    </subject>

Which is doing nothing but Listing critical alert count in the Email subject.

See if you can Makeuse of some thing out of it.

Please give a Accept answer if it did.

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