Customize email alerts in ambari

  • Add the xml file – alert-templates-custom.xml  under  /var/lib/ambari-server/resources/
  • Edit ambari.properties file under /etc/ambari-server/conf/ and add the following property alerts.template.file=/var/lib/ambari-server/resources/alert-templates-custom.xml.
  • Restart the ambari-server.

alert-templates-custom.xml :

 

<?xml version=”1.0″ encoding=”UTF-8″?>
<alert-templates>
<alert-template type=”EMAIL”>
<subject>
<![CDATA[Alert Summary: OK[$summary.getOkCount()], Warning[$summary.getWarningCount()], Critical[$summary.getCriticalCount()], Unknown[$summary.getUnknownCount()]]]>
</subject>
<body>
<![CDATA[
#set( $alertStates = [“OK”, “WARNING”, “CRITICAL”, “UNKNOWN”] )
#set( $services = $summary.getServices() )
<html>
<style type=”text/css”>
html {
font-family:sans-serif;
-webkit-text-size-adjust:100%;
-ms-text-size-adjust:100%;
}
body {
margin:10px;
}
footer,header {
display:block;
}
table {
border-spacing:0;
border-collapse:collapse;
}
td,th {
padding:10px;
}
.panel {
margin-bottom:20px;
background-color:#fff;
border:1px solid transparent;
border-radius:4px;
-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);
box-shadow:0 1px 1px rgba(0,0,0,.05);
}
.panel-body {
padding:15px;
}
.panel-heading {
padding:10px 15px;
border-bottom:1px solid transparent;
border-top-left-radius:3px;
border-top-right-radius:3px;
}
.panel-title {
margin-top:0;
margin-bottom:0;
font-size:16px;
color:inherit;
}
.panel-default {
border-color:#ddd;
}
.panel-default > .panel-heading {
color:#333;
background-color:#f5f5f5;
border-color:#ddd;
}
.panel-primary {
border-color: #337ab7;
}
.panel-primary > .panel-heading {
color: #000;
background-color: #fff;
border-color: #fff;
}
.label {
display:inline;
padding:.3em 1em;
font-size:75%;
font-weight:bold;
line-height:1;
color:#333;
text-align:center;
white-space:nowrap;
vertical-align:baseline;
border-radius:.25em;
}
.label-unknown {
background-color:#fff;
display:inline;
padding:.3em 1em;
font-size:75%;
font-weight:bold;
line-height:1;
text-align:center;
white-space:nowrap;
vertical-align:baseline;
border-radius:.25em;
color:#333;
}
.label-primary {
background-color:#337ab7;
}
.label-ok {
display:inline;
padding:.3em 1em;
font-size:75%;
font-weight:bold;
line-height:1;
text-align:center;
white-space:nowrap;
vertical-align:baseline;
border-radius:.25em;
color:#5CB85C;
}
.label-warning {
display:inline;
padding:.3em 1em;
font-size:75%;
font-weight:bold;
line-height:1;
text-align:center;
white-space:nowrap;
vertical-align:baseline;
border-radius:.25em;
background-color:#fff;
color:#F0AD4E;
}
.label-critical {
display:inline;
padding:.3em 1em;
font-size:75%;
font-weight:bold;
line-height:1;
text-align:center;
white-space:nowrap;
vertical-align:baseline;
border-radius:.25em;
background-color:#fff;
color:#FF0000;
}
.label-small {
font-size:12px;
}
.ambari-footer{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
</style>

Services Reporting Alerts

#foreach( $alertState in $alertStates ) #if( $summary.getServicesByAlertState($alertState) )#end
#end

$alertState $summary.getServicesByAlertState($alertState)

</div>

#foreach( $service in $services )

$service

#foreach( $alertState in $alertStates ) #foreach( $alert in $summary.getAlerts($service,$alertState) )

$alertState $alert.getAlertDefinition().getLabel()

Alert Details: $alert.getAlertText()
Host: $alert.getHostName()

</td>
</tr>
#end
#end
</table>
</div>
</div>
#end

</html>
]]>
</body>
</alert-template>
<alert-template type=”SNMP”>
<subject>
<![CDATA[[$alert.getAlertState()] $alert.getAlertName()]]>
</subject>
<body>
<![CDATA[
[Alert] $alert.getAlertName()
[Service] $alert.getServiceName()
#if( $alert.hasComponentName() )
[Component] $alert.getComponentName()
#end
#if( $alert.hasHostName() )
[Host] $alert.getHostName()
#end

$alert.getAlertText()]]>
</body>
</alert-template>
</alert-templates>

Advertisements

About shalishvj : My Experience with BigData

6+ years of experience using Bigdata technologies in Architect, Developer and Administrator roles for various clients. • Experience using Hortonworks, Cloudera, AWS distributions. • Cloudera Certified Developer for Hadoop. • Cloudera Certified Administrator for Hadoop. • Spark Certification from Big Data Spark Foundations. • SCJP, OCWCD. • Experience in setting up Hadoop clusters in PROD, DR, UAT , DEV environments.
This entry was posted in Hadoop Cluster Administration. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s