SAP Cloud platform, API Management offers many best practices which can be customized based on your requirement. Logging is a bit complex part of SAP APIM. Custom Charts is an option to monitor the APIs based on our own way of representing the graph.

In this blog I’m going to show you how to log and display the error messages on the custom chart using statistics collector policy.

Step: 1

The first step is to create an API Proxy using an URL/provider/proxy in the API Portal.

Once API is created it should be deployed successfully.

Step: 2

Now, go to Analyze tab, Click on +Add and create a custom metric.

Create%20Custom%20Metric

Create Custom Metric

Add the dimension, name it and click on Ok.

Create%20Dimension

Create Dimension

Step: 3

Then create a custom chart.

Create%20Custom%20Chart

Custom Chart

Note: I created custom chart in a Custom_view named custom view. we can also create on existing custom views.

Add Dimensions and Measures for checking the required data to be represented on the Chart.

Here I’m considering API Name, Response Code and Error_Description (Displayed in order on the graph) (Created Dimension) as my Dimensions and Errors, Policy Error, Target Error as my Measures to display on the chart.

Note: Measures are displayed on the Vertical axis and Dimensions are displayed on the Horizontal axis.

Add%20Dimensions%20and%20Measures

Dimensions and Measures

Step: 4

Filter the APIs and Response codes which you want to monitor on the graph (chart)

Filter%20APIs%20and%20Response%20Codes

Filter APIs and Response Codes

Note: Here I’ve filtered out one API (Test_Monitoring) which I created for testing also filtered out with 2xx response codes.

Step: 5

Now open the created API Proxy and add statistics collector policy and API Key policy in the proxy pre flow.

Name of the statistics should be the name created in the custom metric – Dimension Refer. Step 2

Here I used ref=’error.content’ as I wanted to plot the complete error message on the graph. For Reference – https://help.sap.com/docs/SAP_CLOUD_PLATFORM_API_MANAGEMENT/66d066d903c2473f81ec33acfe2ccdb4/edf281e6f1dc43478fd9aa7b5fd2ba32.html

Statistics%20collector%20Policy

Statistics collector Policy

Step: 6

Call the API with Invalid API key or No API key from Postman/API Test Console.

API%20Test%20Console

API Test Console

Step 7:

Now go the created custom chart as the error will be captured and displayed on the custom chart created.

Note 1: Use date-time to filter accordingly to check for a certain time period.

Note 2: Sometimes after creating a chart with custom dimension or custom measure, you’ll experience a delay of 20-30 minutes before data starts appearing in the charts.

Custom%20Chart

Custom Chart

To analyze further open the custom chart and click on the bar.

Custom%20Chart

Custom Chart

Again Click on the bar to check the Response Code.

Custom%20Chart

Custom Chart

Again Click on the bar to check the Error_Description.

Custom%20Chart

Custom Chart

Similarly you can create your own Dimensions and Measures and try plotting them on the graph. 🙂

For more information please visit –

https://help.sap.com/docs/SAP_CLOUD_PLATFORM_API_MANAGEMENT/66d066d903c2473f81ec33acfe2ccdb4/adcbc07b031b4ac285b22867a1216306.html?locale=en-US

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x