VMware Aria Operations for Applications allows for a use of API with all the major Alert functions. Many customers choose to automate the creation, addition and deletion using Aria Operations for Application's API. The same robust Query Language that is used in the user interface can also be utilized within the API.
Problem Description:
When using VMware Aria Operations for Applications Query Language there are functions within the User Interface that may require Double or Single quotes for the function to operate correctly. Using the same query while creating an alert via the VMware Aria Operations for Applications API will produce an error.
Cause:
Unescaped JSON characters
EXAMPLE:
{
"name": “Test_Alert_VMware_Aria_Operations_for_Applications”,
"target": “test@vmware.com",
"condition": "hideAfter(1m, rawpercentile(95, align(1m, mean, default(5m, 0, ts(stats.timers.promotion-service.getBanners.post_checkout_page.latency.upper_95))))) > 1000 and between(hour("US/Pacific"), 6, 23.5)
",
"displayExpression": "hideAfter(1m, rawpercentile(95, align(1m, mean, default(5m, 0, ts(stats.timers.promotion-service.getBanners.post_checkout_page.latency.upper_95))))) > 1000 and between (hour("US/Pacific"), 6, 23.5)
",
"minutes": 15,
"resolveAfterMinutes": 1,
"severity": "INFO",
"additionalInformation": “Failure to include JSON Escape Character after double quotes”,
"tags": {
"customerTags": [
"alertTag1"
]
}
}
Note: The preceding excerpts are only examples. Date, time, and environmental variables may vary depending on your environment.
Error Message:
"message": "Invalid UTF-8 start byte 0x80\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 2, column: 13]", "code": 400
Solution:
Double Quotes are reserved in JSON and must be properly escaped to be used in strings. When using function such as the Hour Function within the UI, Double Quotes are not required to be escaped,
EXAMPLE:
{
"name": "Test_Alert_VMware_Aria_Operations_for_Applications",
"target": "test@vmware.com",
"condition": "hideAfter(1m, rawpercentile(95, align(1m, mean, default(5m, 0, ts(stats.timers.promotion-service.getBanners.post_checkout_page.latency.upper_95))))) > 1000 and between (hour('US/Pacific'), 6, 23.5) ",
"displayExpression": "hideAfter(1m, rawpercentile(95, align(1m, mean, default(5m, 0, ts(stats.timers.promotion-service.getBanners.post_checkout_page.latency.upper_95))))) > 1000 and between (hour('US/Pacific'), 6, 23.5) ",
"minutes": 50,
"resolveAfterMinutes": 1,
"severity": "INFO",
"additionalInformation": "Properly formatted JSON",
"tags": {
"customerTags": [
"alertTag1"
]
}
}
Note: The preceding excerpts are only examples. Date, time, and environmental variables may vary depending on your environment.
Additional Details:
The following characters are reserved in JSON and must be properly escaped to be used in strings:
- Backspace is replaced with \b
- Form feed is replaced with \f
- Newline is replaced with \n
- Carriage return is replaced with \r
- Tab is replaced with \t
- Double quote is replaced with \"
- Backslash is replaced with \\
For more information around JSON format please reference json.org and JSON Escape Strings.
Comments