Tutorial - Monitor published APIs in Azure API Management (2024)

  • Article

APPLIES TO: All API Management tiers

With Azure Monitor, you can visualize, query, route, archive, and take actions on the metrics or logs coming from your Azure API Management service.

Note

Currently, this feature isn't available in workspaces.

In this tutorial, you learn how to:

  • View metrics of your API
  • Set up an alert rule
  • View activity logs
  • Enable and view resource logs

Note

API Management supports a range of additional tools to observe APIs, including built-in analytics and integration with Application Insights. Learn more

Prerequisites

  • Learn the Azure API Management terminology.
  • Complete the following quickstart: Create an Azure API Management instance.
  • Also, complete the following tutorial: Import and publish your first API.

View metrics of your APIs

API Management emits metrics every minute, giving you near real-time visibility into the state and health of your APIs. The following are the most frequently used metrics. For a list of all available metrics, see supported metrics.

  • Capacity - helps you make decisions about upgrading/downgrading your API Management services. The metric is emitted per minute and reflects the estimated gateway capacity at the time of reporting. The metric ranges from 0-100 calculated based on gateway resources such as CPU and memory utilization and other factors.

    Tip

    In the v2 service tiers, API Management replaced the capacity metric with separate CPU and memory utilization metrics. These metrics can also be used for scaling decisions and troubleshooting. Learn more

  • Requests - helps you analyze API traffic going through your API Management services. The metric is emitted per minute and reports the number of gateway requests with dimensions. Filter requests by response codes, location, hostname, and errors.

Important

The following metrics have been retired: Total Gateway Requests, Successful Gateway Requests, Unauthorized Gateway Requests, Failed Gateway Requests, Other Gateway Requests. Please migrate to the Requests metric which provides equivalent functionality.

Tutorial - Monitor published APIs in Azure API Management (1)

To access metrics:

  1. In the Azure portal, navigate to your API Management instance. On the Overview page, on the Monitor tab, review key metrics for your APIs.

  2. To investigate metrics in detail, select Metrics from the left menu.

    Tutorial - Monitor published APIs in Azure API Management (2)

  3. From the drop-down, select metrics you're interested in. For example, Requests.

  4. The chart shows the total number of API calls. Adjust the time range to focus on periods of interest.

  5. You can filter the chart using the dimensions of the Requests metric. For example, select Add filter, select Backend Response Code Category, enter 500 as the value. The chart shows the number of requests failed in the API backend.

Set up an alert rule

You can receive alerts based on metrics and activity logs. In Azure Monitor, configure an alert rule to perform an action when it triggers. Common actions include:

  • Send an email notification
  • Call a webhook
  • Invoke an Azure Logic App

To configure an example alert rule based on a request metric:

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

  2. Select Alerts from the left menu.

    Tutorial - Monitor published APIs in Azure API Management (3)

  3. Select + Create > Alert rule.

  4. In the Select a signal window on the Condition tab:

    1. In Signal type, select Metrics.
    2. In Signal name, select Requests.
    3. In Alert logic, specify a Threshold value, which is the number of occurrences after which the alert should be triggered.
    4. In Split by dimensions, in Dimension name, select Gateway Response Code Category.
    5. In Dimension values, select 4xx, for client errors such as unauthorized or invalid requests. If the dimension value doesn't appear, select Add custom value and enter 4xx.
    6. In When to evaluate, accept the default settings, or select other settings to configure how often the rule runs. Select Next.

    Tutorial - Monitor published APIs in Azure API Management (4)

  5. On the Actions tab, select or create one or more action groups to notify users about the alert and take an action. For example, create a new action group to send a notification email to admin@contoso.com. For detailed steps, see Create and manage action groups in the Azure portal.

    Tutorial - Monitor published APIs in Azure API Management (5)

  6. On the Details tab of Create an alert rule, enter a name and description of the alert rule and select the severity level.

  7. Optionally configure the remaining settings. Then, on the Review + create tab, select Create.

  8. Now, test the alert rule by calling the Conference API without an API key. For example:

    curl GET https://apim-hello-world.azure-api.net/conference/speakers HTTP/1.1 

    An alert triggers based on the evaluation period, and it will send email to admin@contoso.com.

    Alerts also appear on the Alerts page for the API Management instance.

    Tutorial - Monitor published APIs in Azure API Management (6)

Activity logs

Activity logs provide insight into the operations on your API Management services. Using activity logs, you can determine the "what, who, and when" for any write operations (PUT, POST, DELETE) taken on your API Management services.

Note

Activity logs do not include read (GET) operations or operations performed in the Azure portal or using the original Management APIs.

You can access activity logs in your API Management service, or access logs of all your Azure resources in Azure Monitor.

Tutorial - Monitor published APIs in Azure API Management (7)

To view the activity log:

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

  2. Select Activity log.

    Tutorial - Monitor published APIs in Azure API Management (8)

  3. Select the desired filtering scope and then Apply.

Resource logs

Resource logs (Azure Monitor logs) provide rich information about API Management operations and errors that are important for auditing and troubleshooting purposes. When enabled through a diagnostic setting, the logs collect information about the API requests that are received and processed by the API Management gateway.

Note

The Consumption tier doesn't support the collection of resource logs.

To configure resource logs:

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

  2. Select Diagnostic settings.

    Tutorial - Monitor published APIs in Azure API Management (9)

  3. Select + Add diagnostic setting.

  4. Select the logs or metrics that you want to collect.

    You have several options about where to send the logs and metrics. For example, archive resource logs along with metrics to a storage account, stream them to an event hub, or send them to a Log Analytics workspace.

    Tip

    If you select a Log Analytics workspace, you can choose to store the data in the resource-specific ApiManagementGatewayLogs table or store in the general AzureDiagnostics table. We recommend using the resource-specific table for log destinations that support it. Learn more

  5. After configuring details for the log destination or destinations, select Save.

Note

Adding a diagnostic setting object might result in a failure if the MinApiVersion property of your API Management service is set to any API version higher than 2022-09-01-preview.

For more information, see Create diagnostic settings to send platform logs and metrics to different destinations.

View diagnostic data in Azure Monitor

If you enable collection of logs or metrics in a Log Analytics workspace, it can take a few minutes for data to appear in Azure Monitor.

To view the data:

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

  2. Select Logs from the left menu.

    Tutorial - Monitor published APIs in Azure API Management (10)

  3. Run queries to view the data. Several sample queries are provided, or run your own. For example, the following query retrieves the most recent 24 hours of data from the ApiManagementGatewayLogs table:

    ApiManagementGatewayLogs| where TimeGenerated > ago(1d) 

For more information about using resource logs for API Management, see:

  • Log Analytics tutorial, or try the Log Analytics demo environment.

  • Overview of log queries in Azure Monitor.

  • API Management resource log schema reference.

Modify API logging settings

By default, when you create a diagnostic setting to enable collection of resource logs, logging is enabled for all APIs, with default settings. You can adjust the logging settings for all APIs, or override them for individual APIs. For example, adjust the sampling rate or the verbosity of the data, enable logging of headers or request or response payloads, or disable logging for some APIs.

For details about the logging settings, see Diagnostic logging settings reference.

To configure logging settings for all APIs:

  1. In the left menu of your API Management instance, select APIs > All APIs.
  2. Select the Settings tab from the top bar.
  3. Scroll down to the Diagnostic Logs section, and select the Azure Monitor tab.
  4. Review the settings and make changes if needed. Select Save.

To configure logging settings for a specific API:

  1. In the left menu of your API Management instance, select APIs and then the name of the API.
  2. Select the Settings tab from the top bar.
  3. Scroll down to the Diagnostic Logs section, and select the Azure Monitor tab.
  4. Review the settings and make changes if needed. Select Save.

Important

If enabled, logged request or response payloads can be up to 8,192 bytes. API Management also enforces a 32 KB limit for a diagnostic log entry sent to Azure Monitor, which includes the payloads and other attributes such as status codes, headers, and timestamps. If the combined size of the attributes exceeds 32 KB, API Management trims the entry by removing all body and trace content.

Next steps

In this tutorial, you learned how to:

  • View metrics of your API
  • Set up an alert rule
  • View activity logs
  • Enable and view resource logs

Advance to the next tutorial:

Trace calls

Tutorial - Monitor published APIs in Azure API Management (2024)
Top Articles
Why should you learn ReactJs in 2023?
How to Make Additional Income with Your Beauty and Lifestyle Blog • Order Avon Online - Shop Current Brochure
Roblox Roguelike
Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
Locate Td Bank Near Me
Seth Juszkiewicz Obituary
Where's The Nearest Wendy's
今月のSpotify Japanese Hip Hopベスト作品 -2024/08-|K.EG
Med First James City
Summoners War Update Notes
Trini Sandwich Crossword Clue
Flights To Frankfort Kentucky
Local Collector Buying Old Motorcycles Z1 KZ900 KZ 900 KZ1000 Kawasaki - wanted - by dealer - sale - craigslist
What is Rumba and How to Dance the Rumba Basic — Duet Dance Studio Chicago | Ballroom Dance in Chicago
Air Force Chief Results
Accident On The 210 Freeway Today
Robeson County Mugshots 2022
Sussyclassroom
Jail View Sumter
Brbl Barber Shop
Foodsmart Jonesboro Ar Weekly Ad
Gillette Craigslist
897 W Valley Blvd
Maths Open Ref
Does Royal Honey Work For Erectile Dysfunction - SCOBES-AR
N.J. Hogenkamp Sons Funeral Home | Saint Henry, Ohio
Isablove
APUSH Unit 6 Practice DBQ Prompt Answers & Feedback | AP US History Class Notes | Fiveable
Hotel Denizen Mckinney
Solve 100000div3= | Microsoft Math Solver
Tamilrockers Movies 2023 Download
Upstate Ny Craigslist Pets
Texters Wish You Were Here
Old Peterbilt For Sale Craigslist
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
Despacito Justin Bieber Lyrics
Devin Mansen Obituary
New Gold Lee
Doordash Promo Code Generator
Panorama Charter Portal
Achieving and Maintaining 10% Body Fat
Traumasoft Butler
Winta Zesu Net Worth
What to Do at The 2024 Charlotte International Arts Festival | Queen City Nerve
Crystal Glassware Ebay
Take Me To The Closest Ups
Enter The Gungeon Gunther
6463896344
Ocean County Mugshots
ats: MODIFIED PETERBILT 389 [1.31.X] v update auf 1.48 Trucks Mod für American Truck Simulator
La Fitness Oxford Valley Class Schedule
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6085

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.