Knowledge Base

Showing results for 
Search instead for 
Did you mean: 

How can I customize variables in Apache Velocity Templates?

Table of Contents



Sample Payloads for HTTP Request Templates

Additional Resources



If you create health rule policies that trigger HTTP request actions or email notifications, you can use templates to customize the HTTP request or email message and render specific values when the action is triggered. These templates have a set of predefined variables that are processed using Apache Velocity Engine v1.7.


  • For HTTP request actions, templates describe the HTTP request. You can use variables that replace values in the URL path and payload when the HTTP request is sent.
  • For emails, you can use a template with variables to replace values in the body of the message.


You can configure custom variables if you need something beyond the predefined ones. This article provides examples of how you can use different Apache Velocity Template variables in HTTP request action and email templates.



The table below describes widely used Velocity variables to help you become more familiar with Velocity when you are customizing templates. A variable consists of a leading “$” followed by an identifier. It should look like this: $foo


Description Variable
A custom variable Usage: $foo
Set a variable #set ($message = "Hello")
If statement

#if ($message == "Hello")

 Message received and is "Hello"


Replace HTML tags #set( $sm = $sm.replace("<b>", "[") )
Escape characters $${latestEvent.summaryMessage})
Get the first element from an Array/List



Loop through an Array/List #foreach( ${entity} in ${latestEvent.affectedEntities} )${}#if( $foreach.hasNext ),#end#end
Split #set ($summary = ${latestEvent.summaryMessage})
#set ($job = $summary.split(" "))
summary: $summary
Job: $job[2]
Job2: $job.get(2)
Replace #set( $sm = $!{latestEvent.summaryMessage.replace('"',"*")} )
#set( $sm = $sm.replace("<b>", "[") )
#set( $sm = $sm.replace("</b>", "]") )
#set( $sm = $sm.replace("<br>", " ") )


Sample Payloads for HTTP Request Templates 

Attached to this article are three sample payloads for HTTP request templates. 

  • Hipchat
  • Slack
  • ServiceNow


Additional Resources

0 Kudos