Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Modifying the email subject in ambari alert

avatar
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

avatar

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.

View solution in original post

1 REPLY 1

avatar

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.