KQL查询以获取存储帐户已使用空间的百分比

huangapple go评论54阅读模式
英文:

KQL queries to get total storage account used space in percentage

问题

我正在编写KQL查询以设置我们环境中的警报机制。但是,我们在一些警报上遇到了问题。

我需要以百分比的方式获取存储帐户的总使用容量,使用以下查询我能够获取总使用容量,但不是以百分比的方式:

AzureMetrics
| where ResourceProvider == "MICROSOFT.STORAGE"
| where MetricName == "UsedCapacity"
英文:

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"

答案1

得分: 0

我尝试在我的环境中复制相同的操作,以下是结果

> 需要以百分比形式获取存储帐户的总已使用容量,使用以下查询,我能够获取总已使用容量,但不是以百分比形式

您可以使用以下 KQL 查询以百分比形式获取输出。

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)

输出

KQL查询以获取存储帐户已使用空间的百分比

英文:

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

KQL查询以获取存储帐户已使用空间的百分比

huangapple
  • 本文由 发表于 2023年3月9日 15:56:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75681807.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定