Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article provides step-by-step instructions to enable diagnostic logging for a Microsoft Foundry resource. These logs provide rich, frequent data about the operation of a resource that you can use for issue identification and debugging. Before you continue, you must have an Azure account with a subscription to at least one Microsoft Foundry resource.
Prerequisites
To enable diagnostic logging, you need to select a location to store your log data. This tutorial uses Azure Storage and Log Analytics.
- Azure storage - Retains diagnostic logs for policy audit, static analysis, or backup. The storage account doesn't need to be in the same subscription as the resource emitting logs as long as the user who configures the setting has appropriate Azure role-based access control (RBAC) access to both subscriptions.
- Log Analytics - A flexible log search and analytics tool that you can use to analyze raw logs generated by an Azure resource.
Note
- Other configuration options are available. To learn more, see Collect and consume log data from your Azure resources.
- The "Trace" option in diagnostic logging is only available for Custom question answering.
Enable diagnostic log collection
Start by enabling diagnostic logging by using the Azure portal.
Note
To enable this feature by using PowerShell or the Azure CLI, see Collect and consume log data from your Azure resources.
- Go to the Azure portal. Then locate and select a Microsoft Foundry resource.
- Next, from the left-hand navigation menu, locate Monitoring, and select Diagnostic settings. This screen contains all previously created diagnostic settings for this resource.
- If there's a previously created diagnostic setting that you want to use, select it now. Otherwise, select + Add diagnostic setting.
- Enter a name for the setting. Then select Archive to a storage account and Send to log Analytics.
- When prompted to configure, select the storage account and OMS workspace that you want to use to store your diagnostic logs.
Note
If you don't have a storage account or OMS workspace, follow the prompts to create one.
- Select Audit Logs, Request and Response Logs, Azure OpenAI Request Usage, and AllMetrics. For a description of each available log category, see Azure OpenAI monitoring data reference.
- Select Save.
It can take up to two hours before logging data is available to query and analyze, so don't worry if you don't see anything right away.
View logs in Azure Storage
When you route diagnostic logs to a storage account, Azure Monitor writes the emitted log records as JSON blobs. Each log category is stored in its own container named insights-logs-<category> (for example, insights-logs-audit or insights-logs-requestresponse).
- From the Azure portal, locate the Azure Storage resource that you selected when you enabled diagnostic settings.
- From the left-hand navigation menu, locate Data storage and select Containers.
- Select the
insights-logs-<category>container for the log category you want to review, such asinsights-logs-requestresponse. - Drill down through the blob path to find the logs for your resource and time window. The blobs are organized by resource ID and timestamp, for example:
resourceId=/SUBSCRIPTIONS/.../PROVIDERS/MICROSOFT.COGNITIVESERVICES/ACCOUNTS/<resource-name>/y=<year>/m=<month>/d=<day>/h=<hour>/m=00/PT1H.json. - Select the
PT1H.jsonblob, and then select Download to save it. Each blob contains line-delimited JSON, where every line is a single log record.
To learn more about how diagnostic logs are stored, see Azure resource logs. To learn what you can do with blob data in Azure Storage, see Azure Storage.
View logs in Log Analytics
Follow these instructions to explore log analytics data for your resource.
- From the Azure portal, locate and select Log Analytics from the left-hand navigation menu.
- Locate and select the resource you created when enabling diagnostics.
- Under General, locate and select Logs. From this page, you can run queries against your logs.
Sample queries
Here are a few basic Kusto queries you can use to explore your log data.
Run this query for all diagnostic logs from your Microsoft Foundry resource for a specified time period:
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.COGNITIVESERVICES"
Run this query to measure request latency by response code, including the P50, P90, P95, and P99 percentiles:
AzureDiagnostics
| where TimeGenerated between (todatetime('<StartDateTime>') .. todatetime('<EndDateTime>'))
| where ResourceId has "<YourResourceID>"
| where Category == "RequestResponse"
| project TimeGenerated, ResponseCode = ResultSignature, DurationMs, OperationName
| summarize
RequestCount = count(),
P50 = percentile(DurationMs, 50),
P90 = percentile(DurationMs, 90),
P95 = percentile(DurationMs, 95),
P99 = percentile(DurationMs, 99)
by ResponseCode, OperationName
| order by RequestCount desc
Run this query to measure the request count by response code:
AzureDiagnostics
| where TimeGenerated between (todatetime('<StartDateTime>') .. todatetime('<EndDateTime>'))
| where ResourceId has "<YourResourceID>"
| where Category == "RequestResponse"
| project TimeGenerated, ResponseCode = ResultSignature
| summarize RequestCount = count() by ResponseCode
| order by RequestCount desc
Run this query to look at all the emitted Metrics:
AzureMetrics
| where TimeGenerated between (todatetime('<StartDateTime>') .. todatetime('<EndDateTime>'))
| project MetricName, Total, Count, Maximum, Minimum, Average, TimeGrain, UnitName
Next steps
- For the available resource log categories, their associated Log Analytics tables, and the log schemas, see Azure OpenAI monitoring data reference.
- To understand how to enable logging and the metrics and log categories that are supported by the various Azure services, read the Overview of metrics in Microsoft Azure and the Overview of Azure Diagnostic Logs.
- Read Understand log searches in Azure Monitor logs.