Skip to Content
Technical Articles
Author's profile photo Balaji Vengatesh Murugesan

Observability, monitoring and alerting services offered by SAP Business Technology Platform – Part 2


This blog post  is a continuation of my previous post where I gave an intro about observability and SAP’s  product portfolio on observability services. In this blog post  we can see how we can focus on the event data which is very important when an app or microservice runs in the production.

Alert Notification Service for SAP Business Technology Platform

Alerts are useful when we need to know if there are some changes in the behavior (e.g. connectivity to some external service is down ) or there are some operational changes in an application(e.g. when the app is deployed). We can also configure how we need the stakeholders to be notified. There are various notification channels available starting from email to a slack channel.

Alert notification services for SAP Business Technology Platform provides an out of box solution for this. Lets us see how we can setup  alert notification service for your application.

Please note that Alert notification services for SAP Business Technology Platform does not produce any alerts on its own. It acts like a proxy to which different applications and services are sending alerts.  Alert Notification service provides you with a catalogue, depending on the environment with which you are working. This catalogue of alerts is going to grow over time and adopt as many SAP Business Technology Platform services as possible, regardless of the environment.


  1. A cloud foundry Organization to create an instance of alert notification service.
  2. Available service plan and entitlement for the particular subaccount.
  3. you can always check your available services using  ” cf marketpace ” command.


Creating Alert Notification using command line

In order to create an alert notification service use

cf create-service alert-notification standard my-alert-notification-instance

Alert Notification service supports configuration parameters that can be provided by the -c option of the create-service command. The supported JSON format is the same as the exported configuration format but wrapped in a configuration object: {"configuration":{<<>>}}. For more information, see Exporting or Importing Configurations.

An Example.


cf create-service alert-notification standard my-alert-notification-instance -c '{"configuration":{"conditions":[{"name":"demo_condition","propertyKey":"eventType","predicate":"EQUALS","propertyValue":"demo"},


Using a Multitarget Application descriptor

  • Create a deployment descriptor as described in Defining MTA Deployment Descriptors for Cloud Foundry. In the resources element of the JSON, enter the Alert Notification configuration data in its exported form. Adapt any values if necessary.
- name: example-alert-notification
     type: org.cloudfoundry.managed-service
        service: alert-notification
        service-plan: standard


Creating a custom event using Business Technology Platform cockpit and send email notification

  •       Open Alert notifications from service marketplace or navigate from the service-instances.


Alert notification cockpit

  • To create a subscription select subscriptions on the left side of the window and click on   create. A wizard opens.


  • Enter the name of the subscription and click on create.


  • Click on create condition button . You can also select conditions if already specified.
  • Enter a name for the condition and select a condition type, condition and enter an expected  value. For example condition type = eventType contains po.create


  • Click on Assign button, this opens the select Actions.


  •    Click on create Action button .
  •    Select Action type as Email.


  •  Enter the name for your action, optional: Enter a fallback action if required.


  • Enter a email address to which notification has to be sent under Additional properties, then      click on create.


  • Bind the application to trigger standard notifications using cf bind appname

         cf bind-service APP_NAME SERVICE_INSTANCE -c ‘{“name”:”value”,”name”:”value”}’

  • Create a service key which will contain the url, client_id and client_secret for calling the  alerts  when required in an application.
	"url": "",
	"client_id": "b6a3d917-fk05-49cb-a122-3e34567a5b1",
	"client_secret": "pEJBGTfegTY+DANjfm9cDrhyNNoQNwu"
  •  This REST API can be called from the application with POST to trigger notification to the   required source.


  "eventType": "po.create",
  "resource": {
    "resourceName": "purchase order create",
    "resourceType": "app",
    "tags": {
      "env": "dev"
  "severity": "FATAL",
  "category": "ALERT",
  "subject": "application has crashed",
  "body": "Kindly check the app as something has crashed",
  "tags": {
    "ans:correlationId": "30118",
    "ans:status": "CREATE_OR_UPDATE",
    "customTag": "42"

The below code snippets demonstarte how the alert notification can be triggered with                                               NodeJS and java applications


var data = JSON.stringify(json);
        var auth = "xxxxxxxxxxxxxxxxxxxxxxx" + ":" + "xxxxxxxxxxxxxxxxxxxxxxx"
        var buff = Buffer.from(auth);
        var base64auth = "Basic " + buff.toString('base64');

        const options = {
            port: 443,
            path: '/cf/producer/v1/resource-events',
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': data.length,
                'Authorization': base64auth

        const req = https.request(options, (res) => {
            console.log(`statusCode: ${res.statusCode}`)

            res.on('data', (d) => {

        req.on('error', (error) => {


        res.writeHead(rc, {
            'Content-Type': 'application/json'
            state: 1




public void triggeralertnotification(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) throws IOException, Exception{
	String auth = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" + ":" + "xxxxxxxxxxxxxxxxxxxxxxxxxx";
	byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
	String authHeaderValue = "Basic " + new String(encodedAuth);
	   String path = "";
		URL targetURL = new URL (path);
		HttpURLConnection con = (HttpURLConnection) targetURL.openConnection();
		con.setRequestProperty("Content-Type", "application/json");
		con.setRequestProperty("Authorization", authHeaderValue);
		con.setRequestProperty( "charset", "utf-8");
		DataOutputStream postbody = new DataOutputStream(con.getOutputStream());
		postbody.close();"Alert notification called with service url"  + targetURL );
		int sc = con.getResponseCode();"Returning service code "  + sc );
		response.getWriter().println("<p>Alert notification triggered</p>");


	private String getAlertContent() throws Exception{

	InputStream is = getClass().getResourceAsStream("/json/alert.json");
        String json = new BufferedReader(
                  new InputStreamReader(is, StandardCharsets.UTF_8))
					.collect(Collectors.joining("\n"));"Send output mail format" + json);

        return json;


  •  Trigger the endpoint, make an action or trigger the use case in the application where you   require the alert notification to be triggered.


  •  Within few minutes you will receive a mail to the mailbox with all the parameters you had  specified. which would look similar to the screenshot.




Hence alert notification allows an application to trigger alerts to a specified channel like Email, slack or workflow. which helps us to know and analyze the behavior of the application in production scenario’s.

In my  upcoming blog posts lets see how we can create a SAP Business Technology Platform Logging service for cloud foundry.



Assigned Tags

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