SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Take Action Following a SAP HANA Cloud Database Alert with SAP Automation Pilot

Learn how the SAP Automation Pilot can be used together with the SAP Alert Notification service for SAP BTP to react to a SAP HANA database alert.

Overview

🎓 beginner 30 min. SAP HANA CloudBeginnerSAP Alert Notification Service For SAP BTPSAP Automation Pilot

You will learn

  • โœ”How to setup and become familiar with the SAP Automation Pilot
  • โœ”How to create a catalog, an input, and a custom command with multiple executors that will request a storage resize of a SAP HANA database instance
  • โœ”How to trigger a SAP Automation Pilot command from the Alert Notification service

Prerequisites

Prerequisites

  • Have completed the tutorial Alerts in SAP HANA Database and Data Lake that covers alerts and the Alert Notification service.
  • Access to the SAP Business Technology Platform (BTP) that includes the SAP HANA Cloud, SAP Alert Notification service, and the SAP Automation Pilot. These services are available in SAP BTP free tier.
  • An SAP HANA Cloud instance deployed to a Cloud Foundry runtime.

Steps

Intro

A SAP HANA Cloud database or a data lake Relational Engine instance have a set of built-in alerts that when triggered, are sent to the SAP Alert Notification service (ANS). This service, in addition to being able to forward details of the alert to various channels (email, Microsoft Teams, Slack, etc.), can trigger a SAP Automation Pilot command. In this tutorial, a command will be created to attempt to resolve a disk use alert.

overview
overview

SAP Automation Pilot includes provided commands for various services in the BTP, a scheduler, and the ability to create new commands. Examples of the provided commands for a SAP HANA Cloud, SAP HANA database include start, stop, and restart and for Cloud Foundry include GetCfServiceInstance and UpdateCfServiceInstance. Commands can be created using a BASH script, Python, or Node.js as described at Execute Script.

This tutorial will demonstrate the integration between a triggered database alert, SAP Alert Notification service, SAP Automation Pilot, and concludes with an example of requesting a storage resize of a SAP HANA database instance based on a disk usage alert.


Step 1 Get started with the SAP Automation Pilot service
โ€”

The following steps demonstrate how to subscribe to the SAP Automation Pilot service and explore some basic concepts such as commands, inputs, and executions.

  1. In the SAP BTP Cockpit, at the subaccount level, in one of the supported regions, select Service Marketplace, then from the Automation Pilot tile select Create to create a subscription to the SAP Automation Pilot service.

    Note: For trial accounts, SAP Automation Pilot is automatically available from the Service Marketplace, so you can proceed directly to creating a subscription.

    create SAP Automation Pilot
    create SAP Automation Pilot

    If the Automation Pilot service does not appear, it may be that the entitlement needs to be added to the subaccount. To do so, navigate to the subaccount, select Entitlements, Configure Entitlements, Add Service Plans, select Automation Pilot, and add a plan such as free or standard. Do not forget to save the changes made to Entitlements,

    add entitlement
    add entitlement


    The SAP Automation Pilot subscription can be located in a different global account or subaccount from the SAP Alert Notification service and the SAP HANA Cloud database.

    create service
    create service

  2. Under Users, select your user and assign the role collection AutomationPilot_Admin.

    Assign Admin Role
    Assign Admin Role

    Then assign the following Role Collections:

    Assign Role Collections
    Assign Role Collections

    For additional details, see Permissions and Roles.

  3. Once the SAP Automation Pilot service has been created, open its application.

    open application
    open application

    If you receive a permission error, you may need to log out and log in again for the role assigned in the previous step to take effect.

  4. Notice the two sections for catalogs (My Catalogs and Provided Catalogs) containing provided commands and inputs including ones for Cloud Foundry and database lifecycle management.

    Provided Catalogs are groups of commands and inputs that are provided by the SAP Automation Pilot. Those in My Catalogs are catalogs that are user-created and contain created commands and inputs. Catalogs provide a way to group a collection of related commands and inputs.

    Provided catalogs
    Provided catalogs

    Commands can also be scheduled. One example may be to schedule the starting and stopping of a database instance.

  5. It is possible to create executors in a command using BASH, Node.js, Python or Perl. A provided example command is included for each type as shown below.

    script examples
    script examples

  6. Each example inherits from the base ExecuteScript.

    Execute script
    Execute script

    Notice that there are a set of input keys and output keys.

  7. Under Inputs, open the input WelcomeScriptInput.

    script input
    script input

    Examine the description of the input keys and their types.

  8. Open the command PythonScriptCommandExample in Commands.

    Scroll down to the Configuration section, select input and notice that it has as an additional value WelcomeScriptInput shown in the previous step with an alias of scriptInput.

    command input
    command input

  9. Select welcomeScriptExecutor.

    Executor
    Executor

    Notice that it contains the below script and that the parameters, environment, and stdin have their values set from the input WelcomeScriptInput using its alias name of scriptInput.

    Python
    #!/usr/bin/env python3
    
    import sys, os
    
    stdin = sys.stdin.readline()
    env = os.environ.get("GREETING")
    (arg1, arg2) = sys.argv[1:3]
    
    print(f"{env}{arg1} {stdin}{arg2}")
  10. Trigger the command.

    Trigger command
    Trigger command

  11. Executed commands can be viewed under the Executions tab. Options to filter Executions include ID, Owner, Status, and Start periods.

    Executions
    Executions

  12. Under Output Values, click Show to view the output of the successfully run command.

    Show button for output
    Show button for output

    The output will appear in a pop-up.

    Output
    Output

    This value is coming from the output of the welcomeScriptExecutor whose base command ExecuteScript has a parameter named output.

    output definition
    output definition

At this point, you should now have a subscription to the SAP Automation Pilot service and be familiar with some basic concepts of the service such as commands, inputs, and executions.

Step 2 Create a catalog, an input, and a command
+
Step 3 Trigger a command from a SAP Alert Notification service alert
+
Step 4 Increase the storage size of a SAP HANA Cloud database using a command
+
Step 5 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Get started with the SAP Automation Pilot service 2. Create a catalog, an input, and a command 3. Trigger a command from a SAP Alert Notification service alert 4. Increase the storage size of a SAP HANA Cloud database using a command 5. Knowledge check

Learn more →