Monitor Azure Storage
When you have critical applications and business processes that rely on Azure resources, you want to monitor those resources for their availability, performance, and operation. This article describes the monitoring data that's generated by Azure Storage and how you can use the features of Azure Monitor to analyze alerts on this data.
Note
Azure Storage logs in Azure Monitor is in public preview. Classic storage accounts are not supported.
Monitor overview
The Overview page in the Azure portal for each storage resource includes a brief view of the resource usage, such as requests and hourly billing. This information is useful, but only a small amount of the monitoring data is available. Some of this data is collected automatically and is available for analysis as soon as you create the storage resource. You can enable additional types of data collection with some configuration.
What is Azure Monitor?
Azure Storage creates monitoring data by using Azure Monitor, which is a full stack monitoring service in Azure. Azure Monitor provides a complete set of features to monitor your Azure resources and resources in other clouds and on-premises.
Start with the article Monitoring Azure resources with Azure Monitor which describes the following:
- What is Azure Monitor?
- Costs associated with monitoring
- Monitoring data collected in Azure
- Configuring data collection
- Standard tools in Azure for analyzing and alerting on monitoring data
The following sections build on this article by describing the specific data gathered from Azure Storage. Examples show how to configure data collection and analyze this data with Azure tools.
Monitoring data from Azure Storage
Azure Storage collects the same kinds of monitoring data as other Azure resources, which are described in Monitoring data from Azure resources. For more information on the logs and metrics created by Azure Storage, see Azure Storage monitoring data reference.
Metrics and logs in Azure Monitor support only Azure Resource Manager storage accounts. Azure Monitor doesn't support classic storage accounts. If you want to use metrics or logs on a classic storage account, you need to migrate to an Azure Resource Manager storage account. See Migrate to Azure Resource Manager.
You can continue using classic metrics and logs if you want to. In fact, classic metrics and logs are available in parallel with metrics and logs in Azure Monitor. The support remains in place until Azure Storage ends the service on legacy metrics and logs.
Logs in Azure Monitor (preview)
Log entries are created only if there are requests made against the service endpoint. For example, if a storage account has activity in its blob endpoint but not in its table or queue endpoints, only logs that pertain to the blob service are created. Azure Storage logs contain detailed information about successful and failed requests to a storage service. This information can be used to monitor individual requests and to diagnose issues with a storage service. Requests are logged on a best-effort basis.
Log authenticated requests
The following types of authenticated requests are logged:
- Successful requests
- Failed requests, including timeout, throttling, network, authorization, and other errors
- Requests that use a shared access signature (SAS) or OAuth, including failed and successful requests
- Requests to analytics data (classic log data in the $logs container and class metric data in the $metric tables)
Requests made by the storage service itself, such as log creation or deletion, aren't logged. For a full list of the logged data, see Storage logged operations and status messages and Storage log format.
Log anonymous requests
The following types of anonymous requests are logged:
- Successful requests
- Server errors
- Time-out errors for both client and server
- Failed GET requests with the error code 304 (Not Modified)
All other failed anonymous requests aren't logged. For a full list of the logged data, see Storage logged operations and status messages and Storage log format.
Configuration
Platform metrics and the Activity log are collected automatically, but you must create a diagnostic setting to collect resource logs or forward them outside of Azure Monitor. For the process to create a diagnostic setting by using the Azure portal, the Azure CLI, or PowerShell, see Create diagnostic setting to collect platform logs and metrics in Azure.
When you create a diagnostic setting, choose the type of storage that you want to enable logs for, such as a blob, queue, table, or file. Data Lake Storage Gen2 doesn't appear as a storage type. That's because Data Lake Storage Gen2 is a set of capabilities available to Blob storage.
If you create the diagnostic setting in the Azure portal, you can select the resource from a list. If you use PowerShell or the Azure CLI, you need to use the resource ID of the storage type. You can find the resource ID in the Azure portal by opening the Properties page of your storage account.
You also have to specify the categories of operations for which you want to collect logs. The categories for Azure Storage are listed in this table.
Category | Description |
---|---|
StorageRead | Read operations on objects. |
StorageWrite | Write operations on objects. |
StorageDelete | Delete operations on objects. |
Analyzing metric data
You can analyze metrics for Azure Storage with metrics from other Azure services by using Metrics Explorer. Open Metrics Explorer by choosing Metrics from the Azure Monitor menu. For details on using this tool, see Getting started with Azure Metrics Explorer.
This example shows how to view Transactions at the account level.
For metrics that support dimensions, you can filter the metric with the desired dimension value. This example shows how to view Transactions at the account level on a specific operation by selecting values for the API Name dimension.
For a complete list of the dimensions that Azure Storage supports, see Metrics dimensions.
All metrics for Azure Storage are located in these namespaces:
- Microsoft.Storage/storageAccounts
- Microsoft.Storage/storageAccounts/blobServices
- Microsoft.Storage/storageAccounts/fileServices
- Microsoft.Storage/storageAccounts/queueServices
- Microsoft.Storage/storageAccounts/tableServices
For a list of all Azure Monitor support metrics, which includes Azure Storage, see Azure Monitor supported metrics.
Accessing metrics
Tip
To view Azure CLI or .NET examples, choose the corresponding tabs listed here.
List the metric definition
You can list the metric definition of your storage account or the individual storage service, such as the blob, file, table, or queue service. Use the Get-AzMetricDefinition cmdlet.
In this example, replace the <resource-ID>
placeholder with the resource ID of the entire storage account or the resource ID of an individual storage service, such as the blob, file, table, or queue service. You can find these resource IDs on the Properties pages of your storage account in the Azure portal.
$resourceId = "<resource-ID>"
Get-AzMetricDefinition -ResourceId $resourceId
Reading metric values
You can read account-level metric values of your storage account or the individual storage service, such as the blob, file, table, or queue service. Use the Get-AzMetric cmdlet.
$resourceId = "<resource-ID>"
Get-AzMetric -ResourceId $resourceId -MetricNames "UsedCapacity" -TimeGrain 01:00:00
Analyzing log data
You can access resource logs either as a blob in a storage account, as event data, or through Log Analytic queries.
For a detailed reference of the fields that appear in these logs, see Azure Storage monitoring data reference.
Note
Azure Storage logs in Azure Monitor is in public preview. Classic storage accounts are not supported.
Accessing logs in a storage account
Logs appear as blobs stored to a container in the target storage account. Data is collected and stored inside a single blob as a line-delimited JSON payload. The name of the blob follows this naming convention:
https://<destination-storage-account>.blob.core.chinacloudapi.cn/insights-logs-<storage-operation>/resourceId=/subscriptions/<subscription-ID>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<source-storage-account>/blobServices/default/y=<year>/m=<month>/d=<day>/h=<hour>/m=<minute>/PT1H.json
Here's an example:
https://mylogstorageaccount.blob.core.chinacloudapi.cn/insights-logs-storagewrite/resourceId=/subscriptions/
208841be-a4v3-4234-9450-08b90c09f4/resourceGroups/myresourcegroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount/blobServices/default/y=2019/m=07/d=30/h=23/m=12/PT1H.json
Accessing logs in an event hub
Logs sent to an event hub aren't stored as a file, but you can verify that the event hub received the log information. In the Azure portal, go to your event hub and verify that the incoming messages count is greater than zero.
You can access and read log data that's sent to your event hub by using security information and event management and monitoring tools. For more information, see What can I do with the monitoring data being sent to my event hub?.
Accessing logs in a Log Analytics workspace
You can access logs sent to a Log Analytics workspace by using Azure Monitor log queries.
For more information, see Get started with Log Analytics in Azure Monitor.
Data is stored in these tables.
Table | Description |
---|---|
StorageBlobLogs | Logs that describe activity in blob storage. |
StorageFileLogs | Logs that describe activity in file shares. |
StorageQueueLogs | Logs that describe activity in queues. |
StorageTableLogs | Logs that describe activity in tables. |
Logs for Data Lake Storage Gen2 do not appear in a dedicated table. That's because Data Lake Storage Gen2 is not service. It's a set of capabilities that you can enable on a Blob storage account. If you've enabled those capabilities, logs will continue to appear in the StorageBlobLogs table.
Azure Storage Log Analytics queries in Azure Monitor
Here are some queries that you can enter in the Log search bar to help you monitor your Azure Storage accounts. These queries work with the new language.
Use these queries to help you monitor your Azure Storage accounts:
To list the 10 most common errors over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) and StatusText !contains "Success" | summarize count() by StatusText | top 10 by count_ desc
To list the top 10 operations that caused the most errors over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) and StatusText !contains "Success" | summarize count() by OperationName | top 10 by count_ desc
To list the top 10 operations with the longest end-to-end latency over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) | top 10 by DurationMs desc | project TimeGenerated, OperationName, DurationMs, ServerLatencyMs, ClientLatencyMs = DurationMs - ServerLatencyMs
To list all operations that caused server-side throttling errors over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) and StatusText contains "ServerBusy" | project TimeGenerated, OperationName, StatusCode, StatusText
To list all requests with anonymous access over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) and AuthenticationType == "Anonymous" | project TimeGenerated, OperationName, AuthenticationType, Uri
To create a pie chart of operations used over the last three days.
StorageBlobLogs | where TimeGenerated > ago(3d) | summarize count() by OperationName | sort by count_ desc | render piechart
FAQ
Does Azure Storage support metrics for Managed Disks or Unmanaged Disks?
No. Azure Compute supports the metrics on disks. For more information, see Per disk metrics for Managed and Unmanaged Disks.
Next steps
- For a reference of the logs and metrics created by Azure Storage, see Azure Storage monitoring data reference.
- For details on monitoring Azure resources, see Monitor Azure resources with Azure Monitor.
- For more information on metrics migration, see Azure Storage metrics migration.