Azure API Management (APIM) is a fully-managed service that enables organizations to publish, secure, transform, and monitor APIs. The service features multiple types of monitoring and logging:
- Metrics give insights into the state and health of an API Management service instance.
- Analytics show usage details and performance of APIs and operations.
- Diagnostic logs enable detailed debugging and auditing of individual requests.
Although these tools provide all the necessary information to manage an APIM instance, they are located in different places. For example, metrics and analytics have separate views, while diagnostic logs require manual queries in Application Insights. This can be solved by leveraging Azure Workbooks to combine all data sources into a single view. The view results in an interactive experience for managing an APIM instance and can easily be modified for custom requirements.

Azure Workbooks to the Rescue
Azure Workbooks provide a flexible canvas that is made up of parameters, queries, and metrics. A single workbook may contain many metrics and queries that visualize information from different sources. Parameters allow users to select subscriptions or other resources that must be used in a visualization. Also, parameters can be substituted into queries. This results in an interactive monitoring experience that aggregates data from multiple sources. Workbooks can be updated in a visual editor in the browser without writing code. Complexity is limited to writing queries and parameterizing visualizations.
Azure Workbook for APIM
Our Azure Workbook for APIM contains three levels: service level, API level, and operation level. This results in a top-down view, where issues at the service level can be correlated to the level of a single operation. The service level contains the following components:
- Three parameters to select the Azure Subscription, the APIM instance, and the time range.
- Metrics that show the load on the APIM service instance and the number of failed requests.
- A grid that shows detailed Analytics information per API.

The user can specify a specific API in a dropdown parameter on the API level. Selecting an API populates a grid with analytics on the Api operations, allowing users to identify issues with specific operations.

Finally, the user can specify an operation using a dropdown parameter, which triggers a query in Application Insights to retrieve any requests from the diagnostic logs. The requests are shown in a grid, and logged payloads are included in text fields below the table.

Call to Action
Perform the following actions to create the workbook described earlier. Create an empty workbook and import the workbook code that is located here.
Subsequently:
- Select the right subscription, Api Management instance, and time range.
- The metrics and Api details should become visible.
- Configure diagnostic logging to capture requests and payloads for debugging.
The Workbook relies on the properties.resourceId parameter from the Logger definition to determine the correct instance of Application Insights. If this field is missing, manually set the Application Insights instance on the query level.
Conclusion
Azure Workbooks are an excellent tool for building and maintaining monitoring solutions. In addition, they can easily be extended with custom functionality, such as automatic visualization of Api Management request tracing or a custom table from Azure Monitor Logs that contains audit information for APIs.
However, the capabilities to securely query custom data sources are currently limited. For example, although it is possible to include static json or to reference a custom endpoint, there is no way to protect a custom data source. Alternatively, Azure Custom Resource Providers can be used, but these are still in preview.