Azure query for monitoring storage account not working

dave.meijer 0 Reputation points
2023-05-25T08:38:09.2766667+00:00

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

AzureStorageCapacity
| where ResourceId contains "/providers/Microsoft.Storage/storageAccounts/"
| where ResourceId contains "<StorageAccountName>"
| summarize TotalAllocatedSize = sum(TotalCapacity) by StorageType
| join (
    AzureStorageUsage
    | 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,799 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.
2,687 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 13,080 Reputation points
    2023-05-25T14:13:20.77+00:00

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

    AzureMetrics
    |   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