Monitor API Management

APPLIES TO: All API Management tiers

Azure Monitor collects and aggregates metrics and logs from your system to monitor availability, performance, and resilience, and notify you of issues affecting your system. You can use the Azure portal, PowerShell, Azure CLI, REST API, or client libraries to set up and view monitoring data.

Different metrics and logs are available for different resource types. This article describes the types of monitoring data you can collect for this service and ways to analyze that data.

Collect data with Azure Monitor

This table describes how you can collect data to monitor your service, and what you can do with the data once collected:

Data to collect Description How to collect and route the data Where to view the data Supported data
Metric data Metrics are numerical values that describe an aspect of a system at a particular point in time. Metrics can be aggregated using algorithms, compared to other metrics, and analyzed for trends over time. - Collected automatically at regular intervals.
- You can route some platform metrics to a Log Analytics workspace to query with other data. Check the DS export setting for each metric to see if you can use a diagnostic setting to route the metric data.
Metrics explorer Azure API Management metrics supported by Azure Monitor
Resource log data Logs are recorded system events with a timestamp. Logs can contain different types of data, and be structured or free-form text. You can route resource log data to Log Analytics workspaces for querying and analysis. Create a diagnostic setting to collect and route resource log data. Log Analytics Azure API Management resource log data supported by Azure Monitor
Activity log data The Azure Monitor activity log provides insight into subscription-level events. The activity log includes information like when a resource is modified or a virtual machine is started. - Collected automatically.
- Create a diagnostic setting to a Log Analytics workspace at no charge.
Activity log

For the list of all of the data supported by Azure Monitor, see:

Built in monitoring for API Management

Azure API management has the following built in monitoring features.

Get API analytics in Azure API Management

Azure API Management provides analytics for your APIs so that you can analyze their usage and performance. Use analytics for high-level monitoring and troubleshooting of your APIs. For other monitoring features, including near real-time metrics and resource logs for diagnostics and auditing, see Tutorial: Monitor published APIs.

Screenshot of API analytics in the portal.

Note

Currently, this feature isn't available in workspaces.

  • API Management provides analytics using an Azure Monitor-based dashboard. The dashboard aggregates data in an Azure Log Analytics workspace.
  • In the classic API Management service tiers, your API Management instance also includes legacy built-in analytics in the Azure portal, and analytics data can be accessed using the API Management REST API. Closely similar data is shown in the Azure Monitor-based dashboard and built-in analytics.

Important

The Azure Monitor-based dashboard is the recommended way to access analytics data. Built-in (classic) analytics isn't available in the v2 tiers.

With API analytics, analyze the usage and performance of the APIs in your API Management instance across several dimensions, including:

  • Time
  • Geography
  • APIs
  • API operations
  • Products
  • Subscriptions
  • Users
  • Requests

API analytics provides data on requests, including failed and unauthorized requests. Geography values are based on IP address mapping. There can be a delay in the availability of analytics data.

Azure Monitor-based dashboard

To use the Azure Monitor-based dashboard, you need a Log Analytics workspace as a data source for API Management gateway logs.

If you need to configure one, the following are brief steps to send gateway logs to a Log Analytics workspace. For more information, see Tutorial: Monitor published APIs. This procedure is a one-time setup.

  1. In the Azure portal, navigate to your API Management instance.
  2. In the left-hand menu, under Monitoring, select Diagnostic settings > + Add diagnostic setting.
  3. Enter a descriptive name for the diagnostic setting.
  4. In Logs, select Logs related to ApiManagement Gateway.
  5. In Destination details, select Send to Log Analytics and select a Log Analytics workspace in the same or a different subscription. If you need to create a workspace, see Create a Log Analytics workspace.
  6. Make sure Resource specific is selected as the destination table.
  7. Select Save.

Important

A new Log Analytics workspace can take up to 2 hours to start receiving data. An existing workspace should start receiving data within approximately 15 minutes.

Access the dashboard

After a Log Analytics workspace is configured, access the Azure Monitor-based dashboard to analyze the usage and performance of your APIs.

  1. In the Azure portal, navigate to your API Management instance.
  2. In the left-hand menu, under Monitoring, select Analytics. The analytics dashboard opens.
  3. Select a time range for data.
  4. Select a report category for analytics data, such as Timeline, Geography, and so on.

Legacy built-in analytics

In certain API Management service tiers, built-in analytics (also called legacy analytics or classic analytics) is also available in the Azure portal, and analytics data can be accessed using the API Management REST API.

To access the built-in (classic) analytics in the Azure portal:

  1. In the Azure portal, navigate to your API Management instance.
  2. In the left-hand menu, under Monitoring, select Analytics (classic).
  3. Select a time range for data, or enter a custom time range.
  4. Select a report category for analytics data, such as Timeline, Geography, and so on.
  5. Optionally, filter the report by one or more other categories.

Use Reports operations in the API Management REST API to retrieve and filter analytics data for your API Management instance.

Available operations return report records by API, geography, API operations, product, request, subscription, time, or user.

Enable logging of developer portal usage in Azure API Management

This section shows you how to enable Azure Monitor logs for auditing and troubleshooting usage of the API Management developer portal. When enabled through a diagnostic setting, the logs collect information about the requests that are received and processed by the developer portal.

Developer portal usage logs include data about activity in the developer portal, including:

  • User authentication actions, such as sign-in and sign-out
  • Views of API details, API operation details, and products
  • API testing in the interactive test console

Enable diagnostic setting for developer portal logs

To configure a diagnostic setting for developer portal usage logs:

  1. In the Azure portal, navigate to your API Management instance.

  2. In the left menu, under Monitoring, select Diagnostic settings > + Add diagnostic setting.

    Screenshot of adding a diagnostic setting in the portal.

  3. On the Diagnostic setting page, enter or select details for the setting:

    1. Diagnostic setting name: Enter a descriptive name.
    2. Category groups: Optionally make a selection for your scenario.
    3. Under Categories: Select Logs related to Developer Portal usage. Optionally select other categories as needed.
    4. Under Destination details, select one or more options and specify details for the destination. For example, archive logs to a storage account or stream them to an event hub. For more information, see Diagnostic settings in Azure Monitor.
    5. Select Save.

View diagnostic log data

Depending on the log destination you choose, it can take a few minutes for data to appear.

If you send logs to a storage account, you can access the data in the Azure portal and download it for analysis.

  1. In the Azure portal, navigate to the storage account destination.
  2. In the left menu, select Storage Browser.
  3. Under Blob containers, select insights-logs-developerportalauditlogs.
  4. Navigate to the container for the logs in your API Management instance. The logs are partitioned in intervals of 1 hour.
  5. To retrieve the data for further analysis, select Download.

Use Azure Monitor tools to analyze the data

These Azure Monitor tools are available in the Azure portal to help you analyze monitoring data:

  • Some Azure services have a built-in monitoring dashboard in the Azure portal. These dashboards are called insights, and you can find them in the Insights section of Azure Monitor in the Azure portal.

  • Metrics explorer allows you to view and analyze metrics for Azure resources. For more information, see Analyze metrics with Azure Monitor metrics explorer.

  • Log Analytics allows you to query and analyze log data using the Kusto query language (KQL). For more information, see Get started with log queries in Azure Monitor.

  • The Azure portal has a user interface for viewing and basic searches of the activity log. To do more in-depth analysis, route the data to Azure Monitor logs and run more complex queries in Log Analytics.

  • Application Insights monitors the availability, performance, and usage of your web applications, so you can identify and diagnose errors without waiting for a user to report them.
    Application Insights includes connection points to various development tools and integrates with Visual Studio to support your DevOps processes. For more information, see Application monitoring for App Service.

Tools that allow more complex visualization include:

  • Dashboards that let you combine different kinds of data into a single pane in the Azure portal.
  • Workbooks, customizable reports that you can create in the Azure portal. Workbooks can include text, metrics, and log queries.
  • Grafana, an open platform tool that excels in operational dashboards. You can use Grafana to create dashboards that include data from multiple sources other than Azure Monitor.
  • Power BI, a business analytics service that provides interactive visualizations across various data sources. You can configure Power BI to automatically import log data from Azure Monitor to take advantage of these visualizations.

Visualize API Management monitoring data using a Managed Grafana dashboard

You can use Azure Managed Grafana to visualize API Management monitoring data that is collected into a Log Analytics workspace. Use a prebuilt API Management dashboard for real-time visualization of logs and metrics collected from your API Management instance.

On your API Management instance:

  • To visualize resource logs and metrics for API Management, configure diagnostic settings to collect resource logs and send them to a Log Analytics workspace.

  • To visualize detailed data about requests to the API Management gateway, integrate your API Management instance with Application Insights.

    Note

    To visualize data in a single dashboard, configure the Log Analytics workspace for the diagnostic settings and the Application Insights instance in the same resource group as your API Management instance.

On your Managed Grafana workspace:

  • To create a Managed Grafana instance and workspace, see the quickstart for the portal or the Azure CLI.
  • The Managed Grafana instance must be in the same subscription as the API Management instance.
  • When created, the Grafana workspace is automatically assigned a Microsoft Entra managed identity, which is assigned the Monitor Reader role on the subscription. This approach gives you immediate access to Azure Monitor from the new Grafana workspace without needing to set permissions manually. Learn more about configuring data sources for Managed Grafana.

First import the API Management dashboard to your Management Grafana workspace.

To import the dashboard:

  1. Go to your Azure Managed Grafana workspace. In the portal, on the Overview page of your Managed Grafana instance, select the Endpoint link.
  2. In the Managed Grafana workspace, go to Dashboards > Browse > Import.
  3. On the Import page, under Import via grafana.com, enter 16604 and select Load.
  4. Select an Azure Monitor data source, review or update the other options, and select Import.

To use the API Management dashboard:

  1. In the Managed Grafana workspace, go to Dashboards > Browse and select your API Management dashboard.
  2. In the dropdowns at the top, make selections for your API Management instance. If configured, select an Application Insights instance and a Log Analytics workspace.

Review the default visualizations on the dashboard, which appears similar to the following screenshot:

Screenshot of API Management dashboard in Managed Grafana workspace.

Export Azure Monitor data

You can export data out of Azure Monitor into other tools using:

To get started with the Azure Monitor REST API, see Azure monitoring REST API walkthrough.

Use Kusto queries to analyze log data

You can analyze Azure Monitor Log data using the Kusto query language (KQL). For more information, see Log queries in Azure Monitor.

Use Azure Monitor alerts to notify you of issues

Azure Monitor alerts allow you to identify and address issues in your system, and proactively notify you when specific conditions are found in your monitoring data before your customers notice them. You can alert on any metric or log data source in the Azure Monitor data platform. There are different types of Azure Monitor alerts depending on the services you're monitoring and the monitoring data you're collecting. See Choosing the right type of alert rule.

To see how to set up an alert rule in Azure API Management, see Set up an alert rule.

For examples of common alerts for Azure resources, see Sample log alert queries.

Implementing alerts at scale

For some services, you can monitor at scale by applying the same metric alert rule to multiple resources of the same type that exist in the same Azure region. Azure Monitor Baseline Alerts (AMBA) provides a semi-automated method of implementing important platform metric alerts, dashboards, and guidelines at scale.

Get personalized recommendations using Azure Advisor

For some services, if critical conditions or imminent changes occur during resource operations, an alert displays on the service Overview page in the portal. You can find more information and recommended fixes for the alert in Advisor recommendations under Monitoring in the left menu. During normal operations, no advisor recommendations display.

For more information on Azure Advisor, see Azure Advisor overview.