Creating another version of default alerts in WSO2 DAS based APIM Analytics

Umesha Guruge
4 min readJun 6, 2020

--

If you are familiar with WSO2 APIM Analytics, you already know we have different kinds of alerts for different kinds of API-related scenarios such as sudden API failures, abnormal API usages, abnormal response times, etc. If you are not familiar or if you need to learn more about WSO2 APIM Analytics you can refer to this official documentation [1][2].

Today we are going to see how to create another version of an available alert, as you may need to use the same alert with different parameters based on your requirements. Didn’t get what I said? Let me explain further.

For example, if we take the health monitoring alert, the default version will trigger if the invoked API returned response status code greater than or equal to 500, but less than 600 for 5 times continuously. If needed we can change the specified number of times from 5 to any other number as per our use-case.

But imagine we need one alert to be triggered when the specified number of occurrences is 5 and another alert to trigger when the specified number of occurrences is 10. Two different kinds of e-mail subscribers can subscribe to these two versions.

Now that we already have one alert by default, let’s see how we can create the other version.

First, we have to start the server up and log into the analytics management console.

Then navigate through the console as follows:

Main tab → Template manager → Select APIM Analytics Domain → Select Create New Scenario

As we are creating another health monitoring API, the selected scenario type is HealthAvailabilityPerMinAlert.

Fill out the values as required, the scenario name for the new version is HealthAvailabilityPerMin2 and the Response Code Count/Number of continuous responses/Number of continuous response time failures are 10.

Add the scenario and it will be displayed with the other available alert scenario in the list.

Now that the new version of the alert is created but how can we subscribe to it?? For that, we have to make it available in the publisher so the users can subscribe.

To proceed, we have to add our new alert version to the AM_DB database of the API Manager

  • First, log into the AM_DB
  • Then execute the below query against the AM_ALERT_TYPES table.
INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin2', 'publisher');

Here the name of the new alert is healthAvailabilityPerMin2, and as we need to make the new alert publisher-aware the STAKE_HOLDER should be ‘publisher’.

Once this change is done, we can see that the new alert is reflected in the publisher.

Oh yes! both the name and the description are null. I noticed it too.

To overcome this, we need to add the name of our new alert to the locale file of the publisher.

  • Simply navigate to the <wso2am-home>/repository/deployment/server/jaggeryapps/publisher/site/conf/locales/jaggery/ directory
  • Open locale_default.json file.
  • Add the following line (HealthAvailabilityPerMin2 is the scenario name and Health Availability 2 is the name that is needed to be shown in the publisher).
"healthAvailabilityPerMin2": "Health Availability 2",
  • Add the following line to get the alert description ( You can add your own description as required).
"healthAvailabilityPerMin2_Desc": "This alert type gets triggered if at least one of the three cases below are satisfied; Response time of an API > Response time upper percentile of that particular API or Request Count of an API per minute > Request count per minute lower percentile or Response status code >= 500 (By Default) AND Response status code < 600 (By Default)",

Now we can see that the alert will be reflected in the publisher as required.

So now we can subscribe to this new alert version which will get triggered if we get the status code response between 500 and 600 continuously for 10 times for a particular API.

--

--