In this article, we will take a detailed look at the end-to-end scenario of web endpoint monitoring with a real time scenario.
Let’s say we have a couple of web endpoint URLs that use JSON and XML documents representing a breakfast menu. The document consists of the name of the food item, the description, price, and the amount of calories in the food item. With BizTalk360, you can monitor the health of the web endpoint by passing the JSON path/XPath values for the particular XML/JSON document. You can set the expected state of the web endpoint by specifying an expected return value from the endpoint for a particular JSON value or XML value. If the endpoint returns the expected value, the health of the web endpoint will be displayed as HEALTHY. If the expected value is not returned from the endpoint, the health status will be displayed as ERROR or WARNING depending on the status that is set.
The input XML file is attached below. The following table lists the results that are expected for the set value -
|Return Code Setting||Returned Value||Set Value|
|Return Code Alerts||200||200|
|_XPath alerts (XPath is /breakfast_menu/food/price)||$5.95||$7.95|
|Response Time Alerts||< 2 seconds||(Default values)|
Follow the steps as shown below to monitor the health of the XML endpoints. The process remains the same for JSON endpoints also. The only difference will be to enter the JSON Path instead of XPath in the _JSON Path Alerts section while configuring the response time alerts.
- Log in to the BizTalk360 application
- Create a New Alarm. Select For Threshold Monitoring from the drop down.
- Enter the Alarm Name as "Monitor Web Endpoint", enter the email id's to which you want to send the notifications in case of any threshold violation (say, email@example.com), a description for the alarm. Click Next.
- Toggle the Alert on Threshold Violation icon to set the threshold violation. Set the threshold violation persist duration to 10 minutes. Select the "Limit number of alerts per violation to" checkbox to 3. Select the "Notify when things become normal after violation" checkbox to receive an email notification when things become normal after the violation is resolved. Click OK to set up the alarm.
Click 'Monitoring' in the navigation panel. Click the + button against 'Manage Mapping' tab and select 'BizTalk Environment'. Select the Alarm name (Monitor Web Endpoint) from the drop down. In the list of system resources at the top, select Web Endpoints. Click New Web Endpoint button to set up monitoring for the web endpoints.
- Enter a friendly name for the web endpoint to be monitored, and the endpoint URL that you wish to monitor.
- Click Next to navigate to the next section. This is completely an optional section. You can choose only the option that will be required for the endpoint you wish to monitor. To monitor the XML/JSON endpoint, lets skip this section.
- Click Next to navigate to Response alert configuration screen. Select the Response format as XML. Set the Return Code alerts by toggling the green toggle bar. Enter the status code as 200 and Expected Status as Must be Present. Set the Else to throw Error.
- Next, set the _XPath alerts by toggling the green toggle bar. Enter the XPath (or JSON Path) information in the space provided. Set the Expected value to $7.95. Set the Else to throw Warning.
- The Response Time Alerts will be enabled by default. Leave it to the default values of 2 seconds (warning) and 7 seconds (error) respectively.
- Click OK to start monitoring the endpoint
In this case, the Current Status of the web endpoint will be displayed as Warning. This is because the expected value of _XPath alerts is $7.95, and the actual returned value is $5.95, and we have defined the else condition for the mismatch to display Warning. Therefore the status of the endpoint will be overall in the Warning State. In this case, since there is a Warning state in the second return code setting, the third setting will not be validated by the monitoring service. You will see the Current State as? NOT VALIDATED against the Response Time Alerts section in the Endpoint Summary page.
Modification to the scenario
Let's try out a small modification to the above scenario. We will change the Expected value of the XPath (/breakfast_menu/food/price) as $5.95. This will change the status of the endpoint as Healthy and the Endpoint Summary will display the result as shown below.