Skip to content

Commit 42f2785

Browse files
author
gitName
committed
[APIM] LLM logginng
1 parent e394e1a commit 42f2785

15 files changed

+122
-196
lines changed

articles/api-management/TOC.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,6 @@
629629
- name: Azure Policy built-ins
630630
displayName: samples, policies, definitions
631631
href: ./policy-reference.md
632-
- name: Gateway log schema
633-
href: gateway-log-schema-reference.md
634-
- name: Developer portal audit log schema
635-
href: developer-portal-audit-log-schema-reference.md
636632
- name: Event Grid events schema
637633
href: ../event-grid/event-schema-api-management.md?toc=/azure/api-management/toc.json&bc=/azure/api-management/breadcrumb/toc.json
638634
- name: Virtual network configuration

articles/api-management/api-management-howto-use-azure-monitor.md

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: dlepow
77
ms.service: azure-api-management
88
ms.custom: engagement-fy23, devdivchpfy22
99
ms.topic: tutorial
10-
ms.date: 11/01/2024
10+
ms.date: 02/24/2025
1111
ms.author: danlep
1212
---
1313
# Tutorial: Monitor published APIs
@@ -154,55 +154,20 @@ To configure resource logs:
154154
155155
For more information, see [Create diagnostic settings to send platform logs and metrics to different destinations](/azure/azure-monitor/essentials/diagnostic-settings).
156156
157-
## View logs and metrics in Azure Monitor
157+
## View logs and metrics in Azure Log Analytics
158158
159-
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.
160-
161-
To view the data:
162-
163-
1. In the [Azure portal](https://portal.azure.com), navigate to your API Management instance.
164-
1. Select **Logs** from the left menu.
165-
166-
:::image type="content" source="media/api-management-howto-use-azure-monitor/logs-menu-item.png" alt-text="Screenshot of Logs item in Monitoring menu in the portal.":::
167-
168-
1. Run queries to view the data. Several [sample queries](/azure/azure-monitor/logs/queries) are provided, or run your own. For example, the following query retrieves the most recent 24 hours of data from the ApiManagementGatewayLogs table:
169-
170-
```kusto
171-
ApiManagementGatewayLogs
172-
| where TimeGenerated > ago(1d)
173-
```
174-
175-
:::image type="content" source="media/api-management-howto-use-azure-monitor/query-resource-logs.png" alt-text="Screenshot of querying ApiManagementGatewayLogs table in the portal." lightbox="media/api-management-howto-use-azure-monitor/query-resource-logs.png":::
159+
[!INCLUDE [api-management-log-analytics](../../includes/api-management-log-analytics.md)]
176160
177161
For more information about using resource logs for API Management, see:
178162
179163
* [Log Analytics tutorial](/azure/azure-monitor/logs/log-analytics-tutorial).
180164
181165
* [Overview of log queries in Azure Monitor](/azure/azure-monitor/logs/log-query-overview).
182166
183-
* [API Management resource log schema reference](gateway-log-schema-reference.md).
184-
185167
## Modify API logging settings
186168
187-
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.
188-
189-
For details about the logging settings, see [Diagnostic logging settings reference](diagnostic-logs-reference.md).
190-
191-
To configure logging settings for all APIs:
192-
193-
1. In the left menu of your API Management instance, select **APIs** > **APIs** > **All APIs**.
194-
1. Select the **Settings** tab from the top bar.
195-
1. Scroll down to the **Diagnostic Logs** section, and select the **Azure Monitor** tab.
196-
1. Review the settings and make changes if needed. Select **Save**.
197-
198-
To configure logging settings for a specific API:
199-
200-
1. In the left menu of your API Management instance, select **APIs** > **APIs** and then the name of the API.
201-
1. Select the **Settings** tab from the top bar.
202-
1. Scroll down to the **Diagnostic Logs** section, and select the **Azure Monitor** tab.
203-
1. Review the settings and make changes if needed. Select **Save**.
169+
[!INCLUDE [api-management-api-logging](../../includes/api-management-api-logging.md)]
204170
205-
[!INCLUDE [api-management-log-entry-size-limit](../../includes/api-management-log-entry-size-limit.md)]
206171
207172
## Next steps
208173

articles/api-management/developer-portal-audit-log-schema-reference.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

articles/api-management/gateway-log-schema-reference.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

articles/api-management/monitor-api-management.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Monitor Azure API Management
33
description: Learn how to monitor Azure API Management using Azure Monitor, including data collection, analysis, and alerting.
44
ms.date: 01/06/2025
55
ms.custom: horz-monitor
6-
ms.topic: conceptual
6+
ms.topic: concept-article
77
author: dlepow
88
ms.author: danlep
99
ms.service: azure-api-management
@@ -100,47 +100,49 @@ Use [Reports](/rest/api/apimanagement/reports) operations in the API Management
100100

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

103-
### Enable logging of developer portal usage in Azure API Management
103+
### Azure Monitor logs
104104

105-
This section shows you how to enable Azure Monitor logs for auditing and troubleshooting usage of the API Management [developer portal](developer-portal-overview.md). When enabled through a diagnostic setting, the logs collect information about the requests that are received and processed by the developer portal.
105+
This section shows you how to enable Azure Monitor logs for auditing and troubleshooting usage of different features of your API Management instance. By enabling a diagnostic setting, you can enable collection of one or more of the following categories of resource logs:
106106

107-
Developer portal usage logs include data about activity in the developer portal, including:
107+
|Category |Description | Notes |
108+
|---------|---------|-----|
109+
|API Management gateway | Requests processed by the API Management gateway, including HTTP methods, protocols, request and response bodies, headers, timings, error details, and cache involvement. | Adjust settings for all APIs, or override them for individual APIs. |
110+
|WebSocket connections | Events for [WebSocket API](websocket-api.md) connections, starting from the handshake until the connection is terminated. |
111+
|Developer portal usage | Requests that are received and processed by the API Management [developer portal](developer-portal-overview.md), including user authentication actions, views of API details, and API testing in the interactive test console.|
112+
| Large language model (LLM) | Requests processed by the gateway for large language model REST APIs such as Azure OpenAI APIs, including token usage, models, and optionally details of request prompts and response completions. | Enable logging of request messages and/or response messages for specific LLM APIs.
108113

109-
- User authentication actions, such as sign-in and sign-out
110-
- Views of API details, API operation details, and products
111-
- API testing in the interactive test console
114+
For more information, see [API Management monitoring data reference](monitor-api-management-reference.md).
112115

113-
#### Enable diagnostic setting for developer portal logs
114116

115-
To configure a diagnostic setting for developer portal usage logs:
117+
#### Enable diagnostic setting for Azure Monitor logs
116118

117-
1. In the [Azure portal](https://portal.azure.com), navigate to your API Management instance.
118-
1. In the left menu, under **Monitoring**, select **Diagnostic settings** > **+ Add diagnostic setting**.
119+
[!INCLUDE [api-management-diagnostic-settings](../../includes/api-management-diagnostic-settings.md)]
119120

120-
:::image type="content" source="media/developer-portal-enable-usage-logs/monitoring-menu.png" alt-text="Screenshot of adding a diagnostic setting in the portal.":::
121+
#### View log data
121122

122-
1. On the **Diagnostic setting** page, enter or select details for the setting:
123+
Depending on the log destination you choose, it can take a few minutes for data to appear.
123124

124-
1. **Diagnostic setting name**: Enter a descriptive name.
125-
1. **Category groups**: Optionally make a selection for your scenario.
126-
1. Under **Categories**: Select **Logs related to Developer Portal usage**. Optionally select other categories as needed.
127-
1. 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](/azure/azure-monitor/essentials/diagnostic-settings).
128-
1. Select **Save**.
125+
**View logs in Log Analytics workspace**
129126

130-
#### View diagnostic log data
127+
[!INCLUDE [api-management-log-analytics](../../includes/api-management-log-analytics.md)]
131128

132-
Depending on the log destination you choose, it can take a few minutes for data to appear.
129+
**View logs in storage account**
133130

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

136133
1. In the [Azure portal](https://portal.azure.com), navigate to the storage account destination.
137134
1. In the left menu, select **Storage Browser**.
138-
1. Under **Blob containers**, select **insights-logs-developerportalauditlogs**.
135+
1. Under **Blob containers**, select a name for the log data, for example, **insights-logs-developerportalauditlogs** for developer portal usage logs.
139136
1. Navigate to the container for the logs in your API Management instance. The logs are partitioned in intervals of 1 hour.
140137
1. To retrieve the data for further analysis, select **Download**.
141138

139+
#### Modify API logging settings
140+
141+
[!INCLUDE [api-management-api-logging](../../includes/api-management-api-logging.md)]
142+
142143
[!INCLUDE [azmon-horz-tools](~/reusable-content/ce-skilling/azure/includes/azure-monitor/horizontals/azmon-horz-tools.md)]
143144

145+
144146
### Visualize API Management monitoring data using a Managed Grafana dashboard
145147

146148
You can use [Azure Managed Grafana](../managed-grafana/index.yml) to visualize API Management monitoring data that is collected into a Log Analytics workspace. Use a prebuilt [API Management dashboard](https://grafana.com/grafana/dashboards/16604-azure-api-management) for real-time visualization of logs and metrics collected from your API Management instance.

articles/api-management/visual-studio-code-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: azure-api-management
55
author: dlepow
66
ms.author: danlep
77
ms.topic: tutorial
8-
ms.date: 02/20/2025
8+
ms.date: 02/24/2025
99
ms.custom: devdivchpfy22
1010
---
1111

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
author: dlepow
3+
ms.service: azure-api-management
4+
ms.topic: include
5+
ms.date: 02/24/2025
6+
ms.author: danlep
7+
---
8+
9+
When you create a diagnostic setting to enable collection of gateway or LLM resource logs, logging is enabled with default settings, which do not include details of request or responses such as response bodies. 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 gateway log data, enable logging of LLM request or response messages, or disable logging for some APIs.
10+
11+
For details about the logging settings, see [Diagnostic logging settings reference](diagnostic-logs-reference.md).
12+
13+
To configure logging settings for all APIs:
14+
15+
1. In the left menu of your API Management instance, select **APIs** > **APIs** > **All APIs**.
16+
1. Select the **Settings** tab from the top bar.
17+
1. Scroll down to the **Diagnostic Logs** section, and select the **Azure Monitor** tab.
18+
1. Review the settings and make changes if needed. Select **Save**.
19+
20+
To configure logging settings for a specific API:
21+
22+
1. In the left menu of your API Management instance, select **APIs** > **APIs** and then the name of the API.
23+
1. Select the **Settings** tab from the top bar.
24+
1. Scroll down to the **Diagnostic Logs** section, and select the **Azure Monitor** tab.
25+
1. Review the settings and make changes if needed. Select **Save**.
26+
27+
[!INCLUDE [api-management-log-entry-size-limit](api-management-log-entry-size-limit.md)]

0 commit comments

Comments
 (0)