0

I am writing KQL queries to setup alerting mechanism in our environment. However we got blocked for few alerts.

I need to get total used capacity of storage account in percentage, with below query I am able to get total used Capacity but not in percentage:

     AzureMetrics
     |   where ResourceProvider  == "MICROSOFT.STORAGE"
     |   where MetricName        == "UsedCapacity"
halfer
  • 19,824
  • 17
  • 99
  • 186
ramesh reddy
  • 429
  • 2
  • 5
  • 12

1 Answers1

0

I tried to reproduce the same in my environment and below is the result

need to get total used capacity of storage account in percentage, with below query i am able to get total used Capacity but not in percentage

You can use below KQL query to get the output in percentage.

AzureMetrics  
| where ResourceProvider == "MICROSOFT.STORAGE"  
| summarize Totalvalue = sum(Total) by MetricName| as T  
| extend Percentage = round(100.0 * Totalvaule / toscalar(T | summarize sum(Totalvalue)), 2)

Output

enter image description here

Venkat V
  • 2,197
  • 1
  • 1
  • 10
  • thanks Venkat but i would like put condition in the query like | where UsedCapacity > 80% – ramesh reddy Mar 10 '23 at 11:28
  • i hope this works | where MetricName contains "UsedCapacity" and Percentage >= 80 right ? – ramesh reddy Mar 10 '23 at 12:56
  • 1
    AzureMetrics | where ResourceProvider == "MICROSOFT.STORAGE" | summarize Totalvalue = sum(Total) by MetricName| as T | extend Percentage = round(100.0 * Totalvalue / toscalar(T | summarize sum(Totalvalue)), 2) | where Percentage >= 20 You can use above query if you need output with Percentage: https://i.imgur.com/z7umNSI.png – Venkat V Mar 10 '23 at 13:44