THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
The template uses Apache Velocity to render all tokenized content. The following variables are available for use in your template:
Variable | Description | Example | ||
---|---|---|---|---|
$alert.getAlertDefinition() | ||||
$alert.getAlertText() | ||||
$alert.getAlertName() | ||||
$alert.getAlertState() | ||||
$alert.getServiceName() | ||||
$alert.hasComponentName() | ||||
$alert.getComponentName() | ||||
$alert.hasHostName() | ||||
$alert.getHostName() | ||||
$ambari.getServerUrl() | The Ambari Server URL. | |||
$ambari.getServerVersion() | The Ambari Server version. | |||
$ambari.getServerHostName() | The Ambari Server hostname. | |||
$dispatch.getTargetName() | The notification target name. | |||
$dispatch.getTargetDescription() | The notification target description. | |||
$summary.getAlerts(service,alertState) | A list of all alerts for a given service or alert state (OK|WARNING|CRITICAL|UNKNOWN). | |||
$summary.getServicesByAlertState(alertState) | A list of all services for a given alert state (OK|WARNING|CRITICAL|UNKNOWN). | |||
$summary.getServices() | A list of all services. | |||
$summary.getCriticalCount() | The CRITICAL alert count. | |||
$summary.getOkCount() | The OK alert count. | |||
$summary.getTotalCount() | The total alert count. | |||
$summary.getUnknownCount() | The UNKNOWN alert count. | |||
$summary.getWarningCount() | The WARNING alert count. | $summary.getTotalCount() |
Example: Modify Alert EMAIL Subject
...
- Download the alert-templates.xml code as your starting point.
- On the Ambari Server, save the template to a location such as
/var/lib/ambari-server/resources/alert-templates-custom.xml
. Edit the
alert-templates-custom.xml
file and modify the subject link for the<alert-template type="EMAIL">
template:
Code Block <subject> <![CDATA[Petstore Ambari has $summary.getTotalCount() alerts!]]> </subject>
- Save the file.
- Browse to
/etc/ambari-server/conf
directory. - Edit the
ambari.properties
file. Add an entry for the location of your new template file.
Code Block alerts.template.file=/var/lib/ambari-server/resources/alert-templates-custom.xml
- Save the file and restart Ambari Server.