WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
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 // 15 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.

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
  • vCenter Identity Federation with Authelia
  • vCenter Server Identity Federation with Kanidm
  • Quick Tip - Retrieving vCenter Identity Federation Secret Token Expiry
  • vCenter Server Identity Federation with Zitadel

Categories // PowerCLI, VCSA, VMware Cloud on AWS, vSphere Tags // alarm, email, vCenter Server

Comments

  1. *protectedbarname android says

    11/24/2019 at 10:37 pm

    hey great
    it worked for me correctly.
    thanks a lot

    Reply
  2. *protectedleanroid says

    04/07/2020 at 11:28 am

    i used it and worked so nice
    tnx for sharing

    Reply
  3. *protectedandroid app says

    04/23/2020 at 3:43 pm

    so nice
    tnx for sharing

    Reply
  4. *protectedandroid application says

    09/14/2020 at 7:10 am

    awsome content

    Reply
  5. *protectednew music says

    10/06/2020 at 9:12 am

    why i cant share comment

    Reply
    • *protectedgbwhatsapp says

      10/06/2020 at 9:15 am

      try again
      have no problem here

      Reply
  6. *protectedapplication says

    10/06/2020 at 9:14 am

    omg it works

    Reply
  7. *protectedJohn SysAdmin says

    06/01/2021 at 2:28 pm

    William,

    It is helpful to understand who performed an action.

    I was able to include {Target Summary} in the subject line (which includes username) but it is not very useful as the user is deeper into the subject length, making it hard to read/filter.

    Is there any way to include the user name in body of the alert?
    I tried adding {Target Summary} but it treated it as TEXT not a variable.

    Anyway to break down {Target Summary} into a more readable format in the body?
    Thanks in advance.

    Reply
    • *protecteditaish says

      06/29/2021 at 6:17 pm

      hi william,
      i'm also looking for the answer on the question above, your answer will be appreciated.
      in addition, i have a few other things:
      1. can the body of the mail can be reverted to default after you change it by the script you mentioned or you need to delete it and start again?
      2. i created an alarm from the GUI and set email alerts, then I changed the email body with your commands, now I receive 2 mails together, one from the GUI body and subject, and one with the powercli body and subject.
      is it only possible to set the alarm definition from only one tool (gui vs powecli)?
      3. if i'll set the powercli option only, would i see the alarm in the GUI?

      Reply
  8. *protectedChristoph Reeber says

    06/14/2021 at 6:15 am

    Hi Wiliam,

    great example.
    Is there a documentation about the usable variables in the body text?

    Thanks in advance

    Christoph

    Reply
    • William Lam says

      06/14/2021 at 1:38 pm

      Yes, its linked in the blog post 🙂 Search for "also documented here"

      Reply
      • *protectedSrinivas says

        01/13/2023 at 3:07 am

        Hi William

        Greetings!!

        I gave a try by changing the subject line as "Datastore : {Target Name} is {New status}" but it didnt trigger any mail, not sure what Iam missing here, can you please help on this.

        Also I need to customize the mail body content, can you please let us know do we need to edit any file in vcsa appliance or if we need to run thru script where do we need to keep this script file and execute, can you please share some light on this.

        Thanks in advance.

        Regards
        Srinivas

        Reply
  9. *protectedChristoph Reeber says

    06/15/2021 at 2:16 am

    Thanks for the hint, I overlooked the Link in here 🙂

    Reply
  10. *protectedDavid Wagner says

    09/06/2023 at 11:47 am

    Any chance on getting a updated version of this for vCenter 7? I cannot find any information related to what commands to use. The PowerCLI commands listed here do not seem to work on vCenter 7.

    Reply
    • William Lam says

      09/06/2023 at 12:40 pm

      There’s nothing in script that is version specific. Always install latest version of PowerCLI, it’s backwards compat and includes fixes/features. Rather than posting “do not seem to work”, actually post what you’ve tried along with any error message … hard to help without anything useful to go off of

      Reply

Thanks for the comment!Cancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

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

Copyright WilliamLam.com © 2025

 

Loading Comments...