Azure query for monitoring storage account not working

dave.meijer 0 Reputation points

Hi All,

I'm posting here because I'm stuck with a azure query I want to run. Its a storage account that I want to monitor. The storage is scalable, it will expand if the capacity is lower than 10% ( this is done via another tool) Now I want to create an azure alert if the storage is 5% or lower. (because the tool failed 1 time to expand the storage)

I'm trying to use the below query but its not working. The AzureStorageCapacity and AzureStorageUsage are not familiar. I'm running the query on Log Analytics. I checked if I can add a table, but don't know which one.

Does anyone knows this ? Can someone help me?

Regaards, Dave

| where ResourceId contains "/providers/Microsoft.Storage/storageAccounts/"
| where ResourceId contains "<StorageAccountName>"
| summarize TotalAllocatedSize = sum(TotalCapacity) by StorageType
| join (
    | where ResourceId contains "/providers/Microsoft.Storage/storageAccounts/"
    | where ResourceId contains "<StorageAccountName>"
    | summarize CurrentUsage = sum(CurrentValue) by StorageType
) on StorageType
| project StorageType, TotalAllocatedSize, CurrentUsage
Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,082 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
1,826 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 5,170 Reputation points

    Use the Azure Monitor service with a Kusto Query Language (KQL) to query the "UsedCapacity" metric of your storage account

    |   where ResourceProvider  == "MICROSOFT.STORAGE"
    |   where MetricName        == "UsedCapacity"
    |   where SubscriptionId    == "<YourSubscriptionId>"
    |   summarize arg_max(TimeGenerated, ResourceGroup, Resource, Average) by _ResourceId

    You can create an alert rule based on the results of the above query.

    • Azure Monitor > Log Analytics Workspace > Queries > Alerts
    • Run your query and once you have verified your query, click on "New alert rule"
    • On the Condition tab, the Log query will be filled in.
    • Configure the Operator and Threshold value in the alert logic section.
    • Set up Action groups that define a set of actions to take when an alert is fired
    • In the Alert rule details section set the details
    • Create alert rule