How to test email alerts in WSO2 DAS based APIM Analytics

Umesha Guruge
2 min readJan 1, 2020

--

WSO2 APIM Analytics creates alerts for different kinds of API-related scenarios which we should be aware of. Scenarios such as sudden API failures, abnormal API usages, abnormal response times, and etc.

WSO2 DAS based APIM-Analytics currently supports below mentioned alert types

  • Abnormal response time
  • Abnormal backend time
  • Abnormal request counts
  • Abnormal resource access pattern
  • Unseen source IP address
  • Frequent tier limit hitting (tier crossing)
  • Abnormal API usage
  • Availability of APIs (health monitoring)

You can configure and subscribe to these email alerts following the WSO2 official documentation [1] and [2].

Once configured we can test whether the email alerting is working. For example, we can use the alert type Availability of APIs (health monitoring). This alert can be triggered if we receive a response status code greater than or equal to 500 and less than 600 by invoking an API. If this occurs continuously for more than 5 times (default value) you should receive an email notification stating that Server error occurred continuously for 5 or more times.

For this, all we have to do is

  • Create and publish an API with a mock backend which returns the status code 500 in the Publisher.
  • Subscribe to the ‘Health Availability’ alert by ticking the checkbox and adding the relevant email address in the Admin portal.
  • Create an application in the Store and subscribe to the published API.
  • Invoke the API using the generated access token for more than 5 times within one minute.
  • If you have configured correctly you will get an email notification with the subject APIM Analytics Alert: healthAvailabilityPerMin.

Furthermore, we can use tracing to test if there is an issue in sending the email alerts. (Tracing is not recommended for a production environment)

  • Navigate to the APIM-Analytics console → Main tab → Streaming Analytics → Execution Plans → APIMAnalytics-EmailNotification.(This is the email alert related execution plan)
  • And enable tracing for this execution plan.
  • Execute the above scenario which will produce an email alert using an API.
  • Navigate to APIM-Analytics console → Monitor tab → Event Tracer
  • When the executed scenario generates an email, you will see tracing logs of the event.

In order to check if there is an issue with SMTP configurations, we can directly simulate events in order to check whether the server is correctly configured to sending emails.

  • Log in to the Analytics management console
  • Navigate to Manage → Event → Flow.
  • Select the stream org.wso2.analytics.apim.emailAlertStream:1.0.0 (which is the associated stream used to send emails)
  • Once it is loaded click on simulate events on the right side top corner and fill the relevant fields with mock data.
  • Make sure to add the correct email address you need to receive the alert.
  • And see whether you have received the dummy email.

This way you can easily test the email alert configurations of your DAS based APIM Analytics.

--

--

No responses yet