One of the automated actions that can be configured when a vCenter Server Alarm is triggered is to send an email notification. Over the years, I have seen a number of requests and questions about customizing the email and whether an email template exists. I personally have not used this feature much which has been around since the introduction of vCenter Server and mainly because I have always worked in an environment where we had dedicated monitoring tools that provide notifications including emails.
Most recently, I noticed an increase number of questions around this topic and I was curious on whether a solution exists today or if this is still a gap today? A quick Google search landed me on this 2013 VMTN thread which included several workarounds that customers have found. However, the only viable "supported" and "persisted" option at the time within that thread was to use the vSphere API/PowerCLI to customize the alarm action.
While going through this exercise myself, I found that our vSphere UI has had some enhancements since that 2013 thread and I thought it was worth sharing an update in 2019 on how customers can customize both the email subject and body for vCenter Alarms. One thing to note is that there is no generic email template that can be edited, the email customizations are applied on a per-Alarm action basis and this is applicable for both vCenter Server running in a traditional on-premises environment as well as for VMware Cloud on AWS or Dell EMC.
Email Subject
One of the most common request is to change the email subject line so that it contains additional keywords which maybe used for filtering and/or compliance purposes. Once of the nice enhancements about the vSphere HTML5 UI re-design was that the VMware UX team did not just port over the Flash-based vSphere Client but they had the opopournity to improve a number of workflows including vCenter Server Alarm configurations.
In both the prior vSphere C# and Flash Client, the subject line was not configurable using the UI and was only configurable when using the vSphere API or PowerCLI. Given this was a common customization, it made sense to include this in the UI as part of the email notification as shown in the screenshot below. In fact, even the run-time values can easily be added by simply typing "{" and a drop-down list will be provided for the 9 different options that can be used which are also documented here for your reference. Customers can change or add additional information to the subject and this can now be done simply by using the vSphere UI.
Here is an example of what the email notification would look like based on our modified subject line from above:
Email Body
The next level of customization which is not frequently asked about is customizing the body of the email. Unfortunately, this is not configurable using the vSphere H5 Client and must be done using the vSphere API. With PowerCLI, it is very easy to do to update the body of the email to include additional information or simply re-formatting the text to fit your needs. Below is an example that includes a multi-line format as I noticed many of the examples online has everything on a single line, which can make it difficult to read 🙂 If you need to customize the body, then you can use the vSphere API or PowerCLI to simply update both the subject line and body in one shot rather than having to do some of it via the UI or if you wish to simply automate this across a number of important vCenter Alarms.
1 2 3 4 5 6 7 8 9 |
Get-AlarmDefinition -Name "Customer-PowerOn-Action" | New-AlarmAction -Email -To '*protected email*' -Body ' ### virtuallyGhetto Alarm ### {alarmName} triggered on {targetName} virtuallyGhetto Alarm ### ' -Subject '[virtuallyghetto-alarm] {targetName}' |
Note: When you copy the above command, make sure the line breaks are preserved which will ensure you have line breaks in the actual email.
Here is an example of what the email notification would look like based on our modified subject line and body from above:
Hopefully this article makes it clear on how you can customize the various email notifications, which are applied on an individual vCenter Alarm, in a supported and persisted manner. If you have multiple alarms to update, you should definitely Automate this using something like PowerCLI to help speed things up and ensure you do not make any mistakes. One last thing to note is that vCenter Server does not support TLS/SSL-based SMTP servers, a basic email relay may need to be setup if you wish to have vCenter Server send emails. An alternative option is to leverage our vCenter Event Broker Appliance Fling which would allow you to integrate with any email system or any other type of automated triggers for that matter.
hey great
it worked for me correctly.
thanks a lot
i used it and worked so nice
tnx for sharing
so nice
tnx for sharing
awsome content
why i cant share comment
try again
have no problem here
omg it works