Custom KPIs for BTP applications

The monitoring of your custom BTP application with Health Monitoring, Real User Monitoring and Exception Monitoring follows a so-called auto-instrumentation. Whereas Business Process Monitoring requires manual instrumentation, which is based on the nature, that this is custom-defined content.

The setup of a custom KPI consists of the following steps:

  • Defined KPI in Business Process Monitoring Configuration (KPI Management)
  • Instrument your SAP BTP Application
    • General instrumentation steps
    • Business Process Monitoring specific steps (collecting and sending data)
  • Use Custom KPI

 

The definition in the custom KPI in Business Process Monitoring Application is generic, whereas the instrumentation can either be done based on Java or Node.js. 

Custom KPI definition

The definition of the KPI is done in the Business Process Monitoring Application.

Details on Creating Custom KPIs(opens in new tab) are available on the SAP Help Portal.

For the definition and the instrumentation relevant technical aspects of a KPI are name, identifier, service type, header, and data. 


These details are relevant for the instrumentation of the custom KPI and will be used in the specific steps. The instrumentation can either be done based on Java or Node.js.

Remark: The example above shows how to send a single data record for the KPI. This needs to be replaced with the custom data: selection of relevant data records – matching with the definition of the KPI and as per execution point in time. 

Instrument Java

Note: If you are already monitoring your custom SAP BTP application with SAP Cloud ALM – you can proceed with the Business Process Monitoring specific steps.

The following dependency needs to be added to the configuration of your SAP BTP application, please always use the latest version of x-calm-crun-client-api-java:

 <dependency>

       <groupId>com.sap.xdsr</groupId>

        <artifactId>x-calm-crun-client-api-java</artifactId>

        <version>1.5.32</version>

</dependency>

To find the latest version, please check the Version Update for Data Collection Instrumentation Libraries (SAP Help).

Business Process Monitoring Steps (Java)

For Business Process Monitoring a manual instrumentation of your KPI is required. There are generic steps and KPI specific ones. The following codes lines explain on an example how to instrument a KPI incl. a single example record which is send to the KPI once the method is executed.

import com.sap.xdsr.crunclient.api.model.Tenancy;

import com.sap.xdsr.crunclient.api.CrunInstrumentation;

import com.sap.xdsr.crunclient.model.bm.BmData;

 

String kpiId = "ZKPITB0001"; // ID of the KPI as specified in the Business Process Monitoring application

String serviceType = "SAP_CP_CF";

String tenantId = "12345678-1234-1234-1234-123456789abc"; // ID of your SubAccount (as per SAP Cloud ALM Landscape Management)

Tenancy tenancyData = new Tenancy(serviceType);

 

String[] header = new String[] {"ID", "FIELD_1", "FIELD_2", "FIELD_3", "FIELD_4", "TIMESTAMP_UTC"};

 

List<String>[]data = new ArrayList<>();

 

// Single sample Record, replace with your data records String Array

data.add(new String[] { “82757221A8E4645C17002DF03754AB66”, “2”, “2024-06-02”, “438”, “Newark, New Jersey”, “20250228081340“});

 

tenancyData.setBtpSubAccountId(tenantId);

 

CrunInstrumentation sapCloudALM = new CrunInstrumentation();

 

sapCloudALM.sendCrunContentV2(new BmData(kpiId, header, data), tenancyData);

When implementing the KPI the following adjustments of the coding are to be considered:

  • Replace kpiId with the ID you specified in the Business Process Monitoring Application
  • Replace tenantId with the ID of your SAP Cloud ALM subaccount (Landscape Management Application)
  • Maintain the header as per your KPI definition
  • The data must be handed over as an array containing a string array per data record. The example below shows how to send a single data record for the KPI.
  • Schedule the execution of your data collection as per definition of you KPI (Execution of your method, in our example every 60 minutes).

Instrument Node.js

Note: If you are already monitoring your custom SAP BTP application with SAP Cloud ALM – you can proceed with the Business Process Monitoring specific steps.

Business Process Monitoring Steps (Node.js)

For Business Process Monitoring a manual instrumentation of your KPI is required. There are generic steps and KPI specific ones. The following codes lines explain on an example how to instrument a KPI incl. a single example record which is send to the KPI once the method is executed.

const CrunInstrumentation = require('@sap/xotel-agent-ext-js/dist');

const { TenancyObject } = require('@sap/xotel-agent-ext-js/dist/clientlib/model/TenancyObject');

const { BmData } = require('@sap/xotel-agent-ext-js/dist/clientlib/model/bm/BmData');

 

const serviceType = 'SAP_CP_CF';

const kpiId = 'ZKPITB0001'; // ID of the KPI as specified in the Business Process Monitoring application

const tenantId = '12345678-1234-1234-1234-123456789abc'; // ID of your SubAccount (as per SAP Cloud ALM Landscape Management)

 

const tenancyData = new TenancyObject(serviceType);

 

tenancyData.setBtpSubAccountId(tenantId);

kpiValues = [];

 

kpiValues.push([ '82757221A8E4645C17002DF03754AB66', '2', '2024-06-02', '438', 'Newark, New Jersey', '20250228081340' ]);

 

CrunInstrumentation.sendCrunContentV2(

   new BmData(

        kpiId,

        ['ID', 'FIELD_1', 'FIELD_2', 'FIELD_3', 'FIELD_4', 'TIMESTAMP_UTC'], 

        kpiValues

    ),

    tenancyData

);


When implementing the KPI the following adjustments of the coding are to be considered:

  • Replace kpiId with the ID you specified in the Business Process Monitoring Application
  • Replace tenantId with the ID of your SAP Cloud ALM subaccount (Landscape Management Application)
  • Maintain the header as per your KPI definition
  • The data must be handed over as an array containing a string array per data record. The example below shows how to send a single data record for the KPI.
  • Schedule the execution of your data collection as per definition of you KPI (Execution of your method, in our example every 60 minutes).