• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

virtuallyGhetto

  • About
  • Privacy
  • VMware Cloud
  • Home Lab
  • Nested Virtualization
  • Automation
    • VMware Kickstart
    • VMware API/SDK/CLI
    • VMware vMA/VIMA
    • VMware OVF / OVFTOOL
  • Apple Mac
  • VCSA
  • VSAN
You are here: Home / PowerCLI / Customizing vCenter Alarm Email Subject and Body

Customizing vCenter Alarm Email Subject and Body

11/20/2019 by William Lam 7 Comments

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.

PowerShell
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.

More from my site

  • Creating vCenter Alarms based on Task Events such as Folder creation
  • Create vCenter Alarms for monitoring HCX migration events
  • How to run a script from a vCenter Alarm action in the VCSA?
  • How to automatically log all VM configuration changes using a vCenter Server Alarm?
  • New VOBs for creating vCenter Server alarms in vSphere 6.0
Share this...
  • Twitter
  • Facebook
  • Linkedin
  • Reddit
  • Pinterest

Filed Under: PowerCLI, VCSA, VMware Cloud on AWS, vSphere Tagged With: alarm, email, vcenter

Reader Interactions

Comments

  1. barname android says

    11/24/2019 at 10:37 pm

    hey great
    it worked for me correctly.
    thanks a lot

    Reply
  2. leanroid says

    04/07/2020 at 11:28 am

    i used it and worked so nice
    tnx for sharing

    Reply
  3. android app says

    04/23/2020 at 3:43 pm

    so nice
    tnx for sharing

    Reply
  4. android application says

    09/14/2020 at 7:10 am

    awsome content

    Reply
  5. new music says

    10/06/2020 at 9:12 am

    why i cant share comment

    Reply
    • gbwhatsapp says

      10/06/2020 at 9:15 am

      try again
      have no problem here

      Reply
  6. application says

    10/06/2020 at 9:14 am

    omg it works

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Services Business Unit (CSBU) at VMware. He focuses on Automation, Integration and Operation for the VMware Cloud Software Defined Datacenters (SDDC)

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Sponsors

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy