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: 
munishsuri
Participant
CPEA – It is a Cloud Platform Enterprise Agreement, which provides a rich and simpler customer experience in terms of the contract and offers an easier way to leverage cloud services.

More Details can be found here

In this blog, we are going to look into the APIs which are delivered to provide the information on the cloud credits and a very small POC, to put together some of the pieces and built a prototype to monitor the credits information and trigger an event in case of the credits are below a certain threshold.


I am attaching some code reference, but it has to be modified for the use case. Also, some additional knowledge of CF will be a plus to debug and deploy.

So to start with let's have a look at the Resource Consumption APIs available for Feature Set B.

SAP HELP LINK

Git Hub Link for the codelink

in our case, we have 2 global accounts

  1. Feature Set B (CPEA) account

  2. Subscription account


It could be a possibility that there are one, two or even more global accounts in your case, which depends upon the contracts and landscape.

To begin, you have to create an instance of Usage Data Management with a plan reporting-ga-admin and give a CLI friendly name for the instance.

In my case it’s uas. Now create an access_key, we would be needing it as a User-Provided Instance for another global account.

Note : the instance should be created in the Global Account Having Feature Set B.


 

Optional Step (In case of 2 global accounts)

Click on the access_key and copy the credentials, navigate to the global account, and then to the respective sub-account and space where you would want to have alert notifications and other services.

Click on Create -> User-Provided Services, then provide the name of the service (UAS) in our case and copy the credentials copied from the above step and finally click on create to create the instance.


 

Lets Create Business Rules To Determine - what would be alerts and the threshold.

Name of the instance created,

Guide for creation of the Business Rules - link.

 

There are slight changes.

  1. Data Object - for our scenario we need only 1 data object, Name - Threshold, having 1 structure value i.e. value 

  2. Rules for determination of the value.


 

In the above mentioned link of Git, in the file index.js, refer to line 147, for rule service ID - kindly change it accordingly.

 

Next Step - Creation of the alert notification.

Refer to the blog for creation of the alert notification service - Send notification when target endpoint is down using SAP Cloud Platform Alert Notification: Part 1 |...

For accessing the alert notification via APIs, go to the instance of Alert Notification in your space and create a service key with the following configuration.
{
"type":"BASIC"
}

 

Open the access key's credentials and copy the URL, Client ID and Secret and replace the content onwards  line 193.

In line 200, kindly change the name of event to your event name configured while creating the alert notification service . In our case it is mycustomevent .

Once the service is created, we need to create a node JS application, or any other runtime so that we can have a check on the credits and create an alert if required.

As mentioned on the line 117 - link , the function will execute every 10 minutes and trigger the alert.

You may change it at your convenience.

The code might not be up to the mark, but for the POC purpose it should be fine

To deploy the code, you would be needing a manifest.yaml file . - link

 

Kindly change the name of the app, so that there are no discrepancies in the routes.

 

 

 

 
1 Comment