SAP API Logging – Log Error Message using Custom Charts
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.
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.
Now, go to Analyze tab, Click on +Add and create a custom metric.
Then create a 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.
Filter the APIs and Response codes which you want to monitor on the graph (chart)
Note: Here I’ve filtered out one API (Test_Monitoring) which I created for testing also filtered out with 2xx response codes.
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
Call the API with Invalid API key or No API key from Postman/API Test Console.
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.
To analyze further open the custom chart and click on the bar.
Again Click on the bar to check the Response Code.
Again Click on the bar to check the Error_Description.
Similarly you can create your own Dimensions and Measures and try plotting them on the graph. 🙂
For more information please visit –