Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
BiserSimeonov
Product and Topic Expert
Product and Topic Expert

Introduction

SAP HANA Cloud serves as a component in various applications and systems and therefore it is critical for the business operations of numerous organizations. That’s why keeping tabs on the availability of your HANA Cloud instances is crucial for your success. Yet, manually monitoring them, especially when you have multiple instances, can be a tedious and time-consuming task. Wouldn't it be more optimal to have an automated helper keeping a watchful eye for you, alerting you if an instance stops, or better still, starting your HANA instances when they become unavailable?

Welcome to SAP Automation Pilot and SAP Alert Notification Service for SAP BTP – two powerful tools from the SAP Business Technology Platform (SAP BTP) DevOps portfolio. In this blog post, I’m going to walk you through a step-by-step guide on how you can use these innovative tools to transform the way you monitor your HANA Cloud instances, saving you time, preventing potential disruptions, and ensuring your operations continue to run smoothly.

What is SAP Automation Pilot?

Among the vast array of available tools, SAP Automation Pilot has emerged as a solid and competitive cloud application within the SAP Business Technology Platform (BTP) DevOps portfolio, revolutionizing the way DevOps team streamline their ops processes. In a nutshell, SAP Automation Pilot offers low-code / no-code automation capabilities that allow these teams to automate sequences of ops steps, use catalogs of automated commands provided by SAP or build custom executions (if needed), and run scripts in a serverless manner. More details about the product can be found at:

What is SAP Alert Notification service for SAP BTP?

SAP Alert Notification Service for SAP BTP facilitates your DevOps journey in SAP BTP by providing an API that allows providers to publish and consumers to receive events, and if needed, trigger predefined actions (including sending instant notifications over email, Microsoft Teams, etc.). Working seamlessly across cloud-native and hybrid solutions, it sends real-time notifications on events that are crucial for business and operational efficiency. It not only collects vital technical information from SAP BTP services but also possesses the ability to handle information from custom scenarios within your own environment. In essence, it offers a tailored alerting solution adapted to your needs. More details about the product can be found at:

How does the HANA Cloud Availability Check work?

SAP Alert Notification service for SAP BTP provides an array of built-in events that are ingested from HANA Cloud. (For more information, see SAP HANA Cloud Service Database Events.)

However, these events rely on the availability of the HANA Cloud instance. If this instance suddenly becomes unreachable, it won’t be able to trigger an event and you won’t receive a notification about the problem. For this reason, this use case requires a different approach:

SAP HANA Cloud provides a list of metrics, which are exposed through the metrics service REST API and can be used for monitoring and troubleshooting purposes. This metrics service REST API is a generic central service provided by SAP HANA Cloud which can be used by customers to retrieve metrics from each individual SAP HANA Cloud instance through an external secure API from any HTTPS endpoint. Among the many available metrics within this API, the one that SAP Automation Pilot uses to evaluate the availability of your HANA Cloud instance in this scenario is "HDBAccessible". This metric is gathered at 30-second intervals.

SAP Automation Pilot provides you with a sample command, which calls the HANA Cloud Metrics REST API and gets the data from the “HDBAccessible” metric. If the last 3 pings fail, this means that the HANA Instance is not accessible, and SAP Automation Pilot fires an event to SAP Alert Notification service. If the needed subscription is made in Alert Notification service, the service will send a notification (via email or other delivery channel) to the respective team alerting them that their HANA Cloud instance is unavailable. In the meantime, SAP Automation Pilot will trigger a remediation command, which will start the HANA Cloud instance. The process is visualized in the graphic below:

BiserSimeonov_0-1715273779974.png

 

Step-by-Step Guide

Prerequisites:

After you’ve made sure that you meet all the prerequisites, you can proceed with the steps listed below.

1. Verify that you have provisioned SAP Automation Pilot. You should be able to see it in the “Subscriptions” section in your subaccount:

Screenshot 2024-04-03 093105.png

NOTE: SAP Automation Pilot can interact with resources in any BTP landscapes. All you need is to have at least one instance of SAP Automation Pilot.

2. Verify that you have an Alert Notification service instance. You should be able to see it in “Instances” in your space:

Screenshot 2024-04-03 094630.png

3. You need to create a Service Key for your Alert Notification service instance. This key will be used on a later stage by the SAP Automation Pilot command. To create a Service Key, choose the “Create Service Key” option:

Screenshot 2024-04-03 095812.png

4. Enter a name for your service key and choose “Create”:

Screenshot 2024-04-03 105546.png

5. Repeat the previous steps (3, 4) to create a Service Key for your HANA Cloud instance. It will be used on a later stage by the SAP Automation Pilot command.

6. The SAP Automation Pilot team has prepared a catalog with example commands, which can be imported directly into your SAP Automation Pilot instance. Copy the contents of the catalog:

catalog.png

7. Now you need to import the catalog with example commands in your SAP Automation Pilot instance. From the left-side menu, choose “My Catalogs” and then “Import”:

BiserSimeonov_3-1715323711814.png

Paste the catalog and choose “Import”:

Screenshot 2024-04-02 180419.png

8. You can see the imported catalog “Automation Pilot Examples” in “My Catalogs”. From this catalog, choose “Commands”:

Screenshot 2024-04-03 111415.png

9. You can see the CheckHanaCloudAvailabilitySample command. You can open the command by clicking on it:

Screenshot 2024-04-03 111744.png

10. When you open the command, you can explore its components – the Input Keys, the Output Keys, and the Executors:

checkHanaSample.png

11. Scroll down to “Configuration” and choose the “notifyANS” executor. You need to define the event that SAP Automation Pilot will ingest into Alert Notification service. To do that, choose “Edit” to enter the properties of your event:

notifyANS.png

12. You can use these example values for the required event properties of your event:

  • body: The availability check for HANA Cloud with Service Instance ID $(.execution.input.hanaServiceInstance) has failed. Now the Automation Pilot proceeds with an automated START for this HANA Cloud instance.
  • category: ALERT
  • eventType: FailedHCAvailabilityCheck
  • resourceName: hana
  • resourceType: database
  • serviceKey: $(.execution.input.AnsServiceKey) -> use a dynamic expression to get the AnsServiceKey from the inputs
  • severity: ERROR
  • subject: Failed HANA Cloud Availability Check $(nowMillis | toDate("yyyy-MM-dd"))

Screenshot 2024-04-08 101847.png

13. After you have done that, trigger the command:

trigger.png

14. You need to provide values for the following input keys:

  • AnsServiceKey - Service Key for your Alert Notification service instance.
  • BtpTechnicalUserPassword - Password for the SAP BTP technical user you have created and currently maintain active.
  • BtpTechnicalUserUsername - Username for the SAP BTP technical user you have created and currently maintain active.
  • hanaClientID - HANA Client ID - available in your HANA Cloud service key file, look for "clientid".
  • hanaClientSecret - HANA Client Secret ID - available in your HANA Cloud service key file, look for "clientsecret".
  • hanaClientTokenURL - The URL needed to be called in order to generate a token to access your HANA Cloud instance. The URL is built as follows: in the HANA Cloud service key file, in the "uaa" section, look for the specified "url" + add to it /oauth/token?grant_type=client_credentials.
  • hanaCloudRegion - The region where your SAP BTP sub-account is located at, e.g. "cf-eu10".
  • hanaCloudResourceGroup - The name of the CF Space where your HANA Cloud is located at, e.g. "dev", "prod", etc.
  • hanaCloudResourceName - The exact name of your HANA Cloud instance, e.g. "hanaDemo", "hanaProd", etc.
  • hanaCloudSubAccount - The exact "Org Name" of your SAP BTP subaccount where your HANA Cloud instance is located.
  • hanaCluster Needed to access the HANA Cloud API gateway, where 'cluster' typically identifies either a production, pre-production or trial environment.
  • hanaDatacenter - Needed to access the HANA Cloud API gateway, where 'datacenter' is the data center where your HANA Cloud is deployed, i.e. eu10, us10, etc.
  • hanaServiceInstance - The Instance ID of your HANA Cloud instance - it can be found from the provisioned service in BTP Cockpit, look for "Instance ID".

    You can also look at the prepared outputs (no need to provide values for them but it is important to understand what data is returned as the command's output):

    • checkPing - The entire response for the metric "HDBAccessible" returned by HANA Cloud Metrics Service REST API.
    • isHanaCloudAvailable - Check on whether the HANA Cloud instance is available, where: "true" = HANA Cloud is available; "false" = HANA Cloud is not available.
    • resultHanaStart - Check on whether the HANA Cloud instance has been started successfully, where: "true" = HANA Cloud has been started; "false" = HANA Cloud was not started'.

15. Provide values for all input keys and then trigger the command:

trigger2.png

There are two possible options for the outcome of the execution:

Option 1: Your HANA Cloud instance is accessible and the command for starting HANA Cloud has not been triggered. You should be able to see the following execution details:

option1.png

If you click on “Output Values”, you can see the output values for checkPing, isHanaCloudAvailable, and resultHanaStart:

option1values.png

You can verify in SAP Hana Cloud Central that your HANA Cloud instance is up and running:

hanarunning.png

Option 2: Your HANA Cloud instance is not accessible and the command for starting HANA Cloud has been triggered:

option2.png

You can verify in SAP Hana Cloud Central that your HANA Cloud instance is starting:

hanastarting.png

If you click on “Output Values”, you can see the output values for checkPing, isHanaCloudAvailable, and resultHanaStart:

option2values.png

You have successfully performed the HANA Cloud Availability Check via SAP Automation Pilot. Now you can make a subscription in Alert Notification service, so that you can receive a notification when SAP Automation Pilot detects that your HANA Cloud instance is not accessible. If you want to do that, continue with the following steps:

16.  Navigate to your Alert Notification service instance and open it. Choose the “Subscriptions” tab form the left-side menu and then “Create” to create a new subscription:

ans-create.png

17. Enter a name for your subscription and click “Create” to move on to the next step:

Screenshot 2024-04-03 130140.png

18. Next, create a Condition. Give your condition a name. Then define your condition by choosing the event property “eventType”, operand “Is Equal To”, and, in our case, expected value “FailedHCAvailabilityCheck”:

Screenshot 2024-04-05 134313.png

The expected value for “eventType” is the one you provided in step 11:

eventtype.png

19. To finish your subscription in Alert Notification service, select an Action by choosing “Create Action”:

Screenshot 2024-04-03 132354.png

Select the Action Type of your preference, for example “Email”, and choose “Next”:

Screenshot 2024-04-03 132405.png

Give your Action a name, and then provide the email address where you want to receive the email notification:

Screenshot 2024-04-03 132730.png

Screenshot 2024-04-03 132812.png

NOTE: After you have created some of the actions, they are labeled as Not Confirmed. To enable them, you have to confirm them as described in Confirming Actions.

20. Choose “Save” to finish making your subscription. You will see a confirmation that your subscription was created:

Screenshot 2024-04-03 133321.png

You can find more information about Subscriptions, Conditions, and Actions in Configuration Management Using the SAP BTP Cockpit.

21. Now you can test your subscription. If you stop your HANA Cloud Instance and trigger the CheckHanaCloudAvailabilitySample command again, you will receive an email from Alert Notification service with information that the HANA Cloud Availability Check has failed. You can see an example email below:

ans-email.png

22. Alternative: Send notification to a Microsoft Teams channel

To send a notification to a Microsoft Teams channel of your choice, first you need to add an Incoming Webhook to this channel. To do this, follow these steps:

1) In your channel, select “Manage channel” from the “More options” menu:

managechannel.png

2) Choose “Edit”:

editconnectors.png

3) Add the Incoming Webhook:

incominghook.png

4) Provide a name for the incoming webhook and click “Create”:

createhook.png

5) You will be provided with a unique webhook URL. Copy it, as you will need to use it when creating an Action in Alert Notification service. Click “Done” and the webhook will be added to your MS Teams channel.

hookurl.png

6) When creating an Action in Alert Notification service, choose the Microsoft Teams Action Type:

Screenshot 2024-04-05 145849.png

7) Give your Action a name and paste the webhook URL in the URL field. Then choose “Create”:

teamsaction.png

With this configuration, if the HАНА Cloud Availability Check fails, you will receive a notification in the MS Teams channel of your choice. Here’s an example MS Teams notification:

Screenshot 2024-04-08 120625.png

.. and there we have it! You’ve successfully automated the monitoring of your HANA Cloud instances!

Further reading 

As further reading and extra reference materials you can also consult these resources: 

Credits to: @Dan_vL for the valuable content and also for his insights and pointing to it! Moreover, credits to @alisa_dermen for her contribution to this blog-post. Thank you both! 

Wrap-up

In this blog, you've learned to utilize SAP Automation Pilot and SAP Alert Notification service for SAP BTP to effectively monitor the availability of your HANA Cloud instances, and even start the ones that are not accessible. Combining these cutting-edge tools gives you unprecedented control over your operations. So, march ahead, keep disruptions at bay, and embrace a smooth and efficient journey with your HANA Cloud instances with the help of SAP Automation Pilot and SAP Alert Notification service for SAP BTP!