cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Incidents not getting created when using if else statement in json payload section of http request template

Hi,

Let say we have two application named as "ABC" and "XYZ"
In application "ABC" we have lets say 3 health rules named as "HR1", "HR2", "HR3"
In application "XYZ" we have lets say 2 health rules named as "HR4", "HR5"
and so on we can have multiple applications and multiple health rules

What we want to do is create a json payload in HTTP request template such that
1. When a health rule is violated in both the application, and for health rule lets say only "HR1","HR2","HR4" and "HR5" is violating. Then it should execute a json payload in such a way that the incidents must be created for "HR1","HR2","HR4" and "HR5" in service now. (refer payload 1)
2. And if two or more health rules are triggering in same application then how can we create seperate incidents for those health rules.(refer payload 2)

 

payload 1:

#set($hr = ${latestEvent.healthRule.name})
#set($sm = ${latestEvent.summaryMessage})
#set($em = ${latestEvent.eventMessage})
#set($app= ${latestEvent.application.name})
{
"description":"$em",
"short_description":"$sm",
"category":"Application",
"Subcategory":"Business Application"
}
#if($app == "ROMSS_Porvoo_PreProd"){
#if($hr == "CPM_1"){
"cmdb_ci":"ROMSS Porvoo PreProd",
"impact":"2",
"urgency":"2"}
#elseif($hr == "CPM_2"){
"cmdb_ci":"ROMSS Porvoo PreProd",
"impact":"3",
"urgency":"3"}
#elseif($hr == "CPM_3"){
"cmdb_ci":"ROMSS Porvoo PreProd",
"impact":"3",
"urgency":"3"}
#else
#end
}
#elseif($app == "ROMSS_Rotterdam_PreProd"){
#if($hr == "APM_BT_1"){
"cmdb_ci":"ROMSS Rotterdam PreProd",
"impact":"2",
"urgency":"3"}
#elseif($hr == "APM_BT_2"){
"cmdb_ci":"ROMSS Rotterdam PreProd",
"impact":"3",
"urgency":"2"}
#else
#end
#else
#end
}

 

Payload 2:

#set($hr = ${latestEvent.healthRule.name})
#set($sm = ${latestEvent.summaryMessage})
#set($em = ${latestEvent.eventMessage})
{
"description":"$em",
"short_description":"$sm",
"cmdb_ci":"ROMSS Porvoo PreProd",
"category":"Application",
"Subcategory":"Business Application"
}
#if($hr == "CPM_1" OR $hr == "CPM_2"){
"impact":"2",
"urgency":"2"
}
#elseif($hr == "CPM_3"){
"impact":"3",
"urgency":"3"}
#else
"description":"else",
"short_description":"else",
"impact":"4",
"urgency":"4",
#end

 

0 REPLIES 0
On-Demand Webinar
Discover new Splunk integrations and AI innovations for Cisco AppDynamics.


Register Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here