Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
06-03-2021 02:07 PM
Hi.
I'm trying to pass Appdynamics error data to Opsgenie using the HTTP Request Templates to format it in JSON.
My simplest template is :
{
"event_name": "${latestEvent.displayName}",
"event_Message":"${latestEvent.eventMessage}",
}
But this is erroring at Opsgenie because there's a Line Feed in the event message :
The content is not a valid json. Reason: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value at [Source: (String)"{ "event_name": "Business Transaction Error", "event_Message":"
Is there an easy way to escape/replace this in the template?
Thanks
Doug McGibbon
06-04-2021 09:25 AM
An existing Community post, Escaped double quotes in HTTP template links to this reference guide: https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/EscapeTool.html
Please do let me know if you find the post or the reference guide helpful. Since this is a peer-to-peer community, if you happen to find a solution, please come back and share it as a reply to your post. This helps keep the knowledge sharing going forward.
Thanks,
Ryan, Cisco AppDynamics Community Manager
Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.
Check out Observabiity in Action
new deep dive videos weekly in the Knowledge Base.
06-04-2021 12:51 PM - edited 06-04-2021 12:52 PM
Yes, I found that post and the guide, but it's not at all clear. And replacing one character with another is much easier than trying to get rid of a control character. I've already spent several hours trying to do this in various ways, to no avail.
06-06-2021 05:39 AM - edited 06-06-2021 05:42 AM
Hi There
We have done the following in one of our templates, to ensure that the Quotes and line breaks etc. are replaced by other characters. We used *. You can modify and replace it with whatever you require.
You can then add as many processing steps as needed at the start of the template, and then use the final processed message that is left over into your template.
#set ($em = ${latestEvent.eventMessage.replace('"','*')})
#set ( $em = $em.replace('<b>', '*') )
#set ( $em = $em.replace('</b>', '*') )
#set ( $em = $em.replace('<br>', ' ') )
{
"event_name": "${latestEvent.displayName}",
"event_Message":"$em",
}
Otherwise you can remove the values completed as below
#set ($em = ${latestEvent.eventMessage.replace('"','')})
#set ( $em = $em.replace('<b>', '') )
#set ( $em = $em.replace('</b>', '') )
#set ( $em = $em.replace('<br>', '') )
{
"event_name": "${latestEvent.displayName}",
"event_Message":"$em",
}
User | Count |
---|---|
4 | |
3 | |
3 | |
1 | |
1 | |
1 |
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form