Home United States USA — software Using XML Policies to Log and Analyze API Calls from Azure API...

Using XML Policies to Log and Analyze API Calls from Azure API Management

164
0
SHARE

A tutorial on how to add API Logging and monitoring to Azure API Management (APIM) using XML policies and Moesif API Analytics.
Join the DZone community and get the full member experience. Azure API Management (APIM) is a powerful platform that enables you to publish and scale APIs while ensuring they are secured. One of the great features of Azure APIM is that you can add plugins and transforms to your APIs without any code change or restarts. These capabilities are deployed using XML Policies which are a collection of statements. Moesif API Observability can be added in just a few minutes using an XML policy for APIM which makes it easy get visibility into API calls, even ones that are rejected and never reach your underlying service. API Observability enables engineering and business to deeply understand how their APIs are used and identify what needs to be fixed before customers email support and overwhelm your team. Unlike classic API monitoring which usually probes an endpoint for typical “Red, Yellow, Green” status, API Observability enables leaders to observe any behavior happening with the API. Some examples include: In order for API Observability to work, a monitoring agent needs to passively log API traffic to an observability service. This can be a custom build on a data warehouse like Azure Synapse Analytics or a turnkey solution like Moesif. An API Gateway like Azure APIM provides a natural point to centralize API logs. Otherwise, each service would need to have it’s own SDK. This solution is deployed using an Azure Resource Manager Template, which automatically adds a few components to your Azure subscription: A diagram is below showing how the solution is deployed in your Azure subscription. Once the API logs are received by Moesif, the rest of the data processing and analytics is handled by the service. A goal for API analytics is to gain an understanding on who is using your APIs and how they use them. To enable this, the integration will automatically associate API calls to specific user profiles. By default, The XML policy will also extract user info like the User Id, First Name, and Email from the context. User object and saved as part of a user profile in Moesif. You can always add additional user properties using Moesif’s user tracking. A critical report is understanding which customers are using your APIs the most. Because we are tracking name and email, we can open a report in Moesif showing weekly API traffic by company name. With high-cardinality, high-dimension API observability, you can slice and dice your API logs by any number of fields such as the URI Route, HTTP headers, and even fields in the payload enabling you to drill into issues impacting customers.

Continue reading...