As an operator, you can use SAP Monitoring service to receive notifications and to fix Java application issues when critical metrics are detected. That way a custom application can notify you through different channels when a critical metric persists for some time. Consequently, the application can take the necessary actions to prevent the Java application from undesired outcomes such as crashes and loss of data.
Currently, you can use the SAP BTP tools to configure email notifications only for availability checks and custom JMX checks of running Java applications. That means SAP BTP can send you an email alert for any critical custom metrics and availability checks. For more information, see Configuring Availability Checks from the Console Client and JMX Checks.
Now by using SAP Monitoring service, you can configure notifications for all the metrics of a Java application. That way you can be notified for any critical CPU and memory usage in addition to the custom metrics and availability checks. Furthermore, you can even customize the way these notifications are sent. For example, SAP Monitoring service can send an email when a metric is detected as critical for the first time and an SMS when it is received as critical three times. Another benefit with such a scenario is that you can be notified for critical metrics of many Java applications located in subaccounts on different hosts (regions). The only requirement in such a case is that your user is a member of those subaccounts.
To use SAP Monitoring service in such a scenario, you just need to develop a notification application that checks for a critical metric and sends notifications through email, SMS, or other channel. To use a channel other than email, you have to configure your server to support it.
This blog describes a scenario in which notifications are sent via email or SMS and assumes that you have configured your server for SMS notifications. A separate tutorial describes in detail how you can develop your notification application in Java (see Tutorial: Implementing a Notification Application).
The communication between your notification application and SAP Monitoring service works as follows:
- A notification application requests metrics of a Java application from SAP Monitoring service with a REST API call every minute. Note: The calls are sent per minute because the Java application metrics are refreshed each minute. For more information about the REST call, see Metrics API.
- SAP Monitoring service sends back a JSON response with a status code 200 OK. The response contains the metrics of the requested application and the states of these metrics.
- The notification application parses the JSON response and checks for critical metrics.
- The notification application notifies you by the following conditions:
- A metric is critical for the first time – you receive a notification email.
- A metric is critical three times – you receive an SMS.
- The notification application checks if metrics have been critical three times and takes actions for application self-healing (for example, the Java application is restarted).
- The notification application repeats steps 1 to 5 for all other Java applications.
Julie Armstrong, as an operator of Company A, would like to configure a notification application that will send her alerts for critical metrics of her running Java applications. These Java applications are located in the US and Europe regions. In addition, she decides that when critical metrics are received, the application has to be restarted. For that purpose, she develops a notification application in Eclipse following the instructions in Tutorial: Implementing a Notification Application.
Although this blog describes only the notification and self-healing scenario, you can extend this scenario to use a dashboard application or another tool that displays the metrics of Java applications. For more information about the dashboard application scenario, see Use the Monitoring Service to Retrieve Metrics from Different Java Applications in the Neo Environment.