Skip to Content
Technical Articles

Send notification when target endpoint is down using SAP Cloud Platform Alert Notification: Part 1

SAP Cloud Platform API Management enables you to manage the end to end lifecycle of your APIs, expose your APIs securely to your developer / partner ecosystem for omni-channel access.  Since the APIs are managed are SAP Cloud Platform API Management , it is easier to track whenever the target service endpoint is unavailable, detect any threat like a sudden spike in the number of API calls. SAP Cloud Platform Alert Notification enables providers to publish alerts and for consumers to subscribe to these alerts.  To know more about features, pricing and data center availability of SAP Cloud Platform Alert Notification service visit SAP Cloud Platform site.

Using SAP Cloud Platform Alert Notification service you can publish alerts from SAP Cloud Platform API Management to inform the consumer whenever such changes are detected. To learn more about SAP Cloud Platform Alert Notification service visit this blog from Kiril.

In this blog series, we have showcased how to use the SAP Cloud Platform Alert Notification service to send alerts email, whenever the target service managed by SAP Cloud Platform API Management is unavailable. In the part 1 of the blog we will learn the steps to configure a subscription in SAP Cloud Platform Alert Notification service, so that we can raise alerts whenever the target service managed by SAP Cloud Platform API Management is down.

Note:- SAP Cloud Platform Alert Notification service is not available in SAP Cloud Platform trial tenants.

Alert and notification is available in both Neo and Cloud Foundry environment. In this blog, we have used the Neo environment. In case you would like to configure Alert & Notification service in your Cloud Foundry environment then follow the help documentation

 

Enable SAP Cloud Platform Alert Notification Service

In this section,  steps to enable the SAP Cloud Platform Alert Notification service has been captured. You can skip this section if you have already activated or enabled SAP Cloud Alert Notification service in your sub-account.

Logon to your SAP Cloud Platform account and select the sub-account where SAP Cloud Platform Alert Notification service is available.  Under the services tab you would find all the available SAP Cloud Platform services for your SAP Cloud Platform sub-account.  SAP Cloud Platform Alert Notification is available under the DevOps category. Navigate to Services, from the drop down select DevOps.

By default, SAP Cloud Platform Alert Notification service may not have been enabled in your sub-account. Select the service to enable it.

 

Click on the Enable , to enable the service. This may take some minutes, so wait while the tenant of Alert Notification service is being provisioned for you.

Once the Alert Notification Service is enabled, the status would change to Enabled and now you are ready to configure the Alert subscriptions.  To learn about Alert Notification Service like features, capabilities, administration click on the Documentation link.

 

Create a new subscription to send email notification when the target service is unavailable

Event Subscription allows you to subscribe to a specific technical events and also define the actions that you would like to take when the alert is raised.  In this section, steps to create an event subscription to send email when the target service managed by SAP Cloud Platform API Management is unavailable.

Navigate to Subscriptions tab of your SAP Cloud Platform Alert Notification service, click on Create button to create a new subscription.

 

This would launch a create subscription wizard. In the wizard enter a subscription name APITargetEndPointError and description say API Target endpoint error.

 

Next step is to Select the conditions for the Subscription, you can select from your existing conditions or create a new condition.  In this blog, we would be creating a new condition. To create a new condition, click on Create Condition

 

 

Enter a condition name say APITargetEndpointDown and then provide your condition. In this example, we have selected condition of eventtype with value targetserviceunavailable.  This even type will be used to raise alerts from SAP Cloud Platform API Management, whenever the backend service is unavailable.

 

With the conditions created, we can start to assign it to an Action. Action defines what Alert Notification service do, once the alerts are raised.  Click Assign to define your Action.

 

Actions allows you define how you would like to take action when the alerts is raised and matches the conditions that is defined by you. You can select from your Available actions list or create a new Action . In this example, we would be creating a new Action.  To create action click on Create Action button.

 

Alert Notification services supports various types of Actions like Send an email to specified email address or Slack message to a specific slack channel or trigger your webhooks for your own customized action. To know more about the various Actions type and their configuration refer the help documentation  . In this example, we would be sending an email whenever the alerts is raised.  Select Email from the Available types of Actions.

 

Enter a name for your Action, say sendtargetunavailableemail and then provide your email address under additional properties.   This would trigger an activation or confirmation code to be send to your configured email address, therefore provide a valid email address.

 

Select the newly created action from the available actions, then click on Assign.

With this an Event subscription has been created to receive alerts from the providers.

 

You will now receive an email with your activation code in the configured email address. This activation needs to be configured back on the Alert Notification service to receive email alerts. Copy the activation code, from your confirmation email.

 

The confirmation code sent by the SAP Cloud Platform Alert Notification service must be confirmed. To confirm this, navigate to Actions tab of your Alert Notification service and select the newly create action , say sendtargetunavailableemail .

Click on Confirm Action to complete the confirmation step.

In Confirm Action dialog, enter your activation code and then select Confirm.

 

With this configuration on the Alert Notification subscription is successfully completed, so that whenever the providers raises an alert which matches the condition of eventtype equal to targetserviceunavailable, SAP Cloud Platform Alert Notification service would send an email notification to the configured email address.

Acquiring API Access Credentials

SAP Cloud Platform Alert Notification provides Producer APIs to publish alerts from any sources. More details about the Producer API is available in help documentation.  To integrate using the Producer API, an API access credentials is required. SAP Cloud Platform Alert Notification supports both OAuth and Basic Authentication.  In this blog, we will learn the steps to create technical client for Basic Authentication. More about the API Access Credential is available in help documentation.   In case you already have technical client for Basic Authentication configured, this steps can be skipped.

Navigate to Security tab. Under the section Endpoints, the link to the Producer Events is available.  We would be using this API from SAP Cloud Platform API Management in our next blog.  To acquire an API access credentials, Click on Create Technical Client.

 

In the Create Technical Client dialog, select ANS_BASIC_CUSTOMER_IDENTITY as the Client type for Basic Authentication. Provide a description say ANS basic auth user. For the permission you can select either both ALERT_WRITE and ALERT_READ or at least the ALERT_WRITE permission to invoke the Produce Events API.  Click on Create.

 

After the technical client is created, you would receive the Cliend ID and Client Secret which can be used as user name and password respectively in Basic Authentication. We would be using the client id and secret from SAP Cloud Platform API Management in our next blog, so save this or make a note of it.Note, the client secret especially can’t be retrieved later, therefore copy it from this screen before proceeding to the next part of the blog.

With this have successfully completed all the configuration on the SAP Cloud Platform Alert Notification side. In the next part of the blog, we will cover the configuration on the SAP Cloud Platform API Management to raise Alerts when the target service is unavailable.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.