AzureMetrics 表的查询

有关在 Azure 门户中使用这些查询的信息,请参阅 Log Analytics 教程。 有关 REST API,请参阅查询

HTTP 响应代码的饼图

过去 12 小时内每个指标的响应代码明细。

AzureMetrics 
| where TimeGenerated > ago(12h)  
| where MetricName in ("Http2xx", "Http3xx", "Http4xx", "Http5xx") 
| summarize sum(Total) by MetricName  
| render piechart

响应时间的折线图

平均响应时间(超过 5 分钟间隔)的时序。

AzureMetrics 
| extend timeBin = bin(TimeGenerated, 5m) 
| summarize ResponseTime = sumif(Average, MetricName=="AverageResponseTime") by timeBin, bin(TimeGenerated, 1h) 
| sort by TimeGenerated desc 
| render timechart

[经典] 在 AzureMetrics 中查找

[经典] 在 AzureMetrics 中查找以在 AzureMetrics 表中搜索特定值。/n请注意,此查询需要更新 <SeachValue> 参数,才能生成结果

// This query requires a parameter to run. Enter value in SearchValue to find in table.
let SearchValue =  "<SearchValue>";//Please update term you would like to find in the table.
AzureMetrics
| where * contains tostring(SearchValue)
| take 1000

最新指标

显示每个报告的指标的最新指标报告。

AzureMetrics 
| summarize arg_max(TimeGenerated, UnitName, Total, Count, Maximum, Minimum, Average) by MetricName

在 AzureMetrics 中查找

在 AzureMetrics 中查找以在 AzureMetrics 表中搜索特定值。/n请注意,此查询需要更新 <SeachValue> 参数,才能生成结果

// This query requires a parameter to run. Enter value in SearchValue to find in table.
let SearchValue =  "<SearchValue>";//Please update term you would like to find in the table.
AzureMetrics
| where * contains tostring(SearchValue)
| take 1000

ExpressRoute 线路 BitsInPerSecond 流量图

流量图 BitsInPerSecond(过去一小时)。

AzureMetrics
| where MetricName == "BitsInPerSecond"
| summarize by Average, bin(TimeGenerated, 1h), Resource
| render timechart

ExpressRoute 线路 BitsOutPerSecond 流量图

流量图 BitsOutPerSecond(过去一小时)。

AzureMetrics
| where MetricName == "BitsOutPerSecond"
| summarize by Average, bin(TimeGenerated, 1h), Resource
| render timechart

ExpressRoute 线路 ArpAvailablility 图

ArpAvailability 的流量图(5 分钟)。

AzureMetrics
| where MetricName == "ArpAvailability"
| summarize by Average, bin(TimeGenerated, 5m), Resource
| render timechart

ExpressRoute 线路 BGP 可用性

BgpAvailability 的流量图(5 分钟)。

AzureMetrics
| where MetricName == "BgpAvailability"
| summarize by Average, bin(TimeGenerated, 5m), Resource
| render timechart

平均 CPU 使用率

按资源名称列出的过去一小时平均 CPU 使用率。

//consistently high averages could indicate a customer needs to move to a larger SKU
AzureMetrics
| where ResourceProvider == "MICROSOFT.SQL" // /DATABASES
| where TimeGenerated >= ago(60min)
| where MetricName in ('cpu_percent') 
| parse _ResourceId with * "/microsoft.sql/servers/" Resource  // subtract Resource name for _ResourceId
| summarize CPU_Maximum_last15mins = max(Maximum), CPU_Minimum_last15mins = min(Minimum), CPU_Average_last15mins = avg(Average) by Resource , MetricName

性能故障排除

可能会在系统上查询或死锁,这可能会导致性能不佳。

//potentially a query or deadlock on the system that could lead to poor performance
AzureMetrics
| where ResourceProvider == "MICROSOFT.SQL"
| where TimeGenerated >=ago(60min)
| where MetricName in ('deadlock')
| parse _ResourceId with * "/microsoft.sql/servers/" Resource // subtract Resource name for _ResourceId
| summarize Deadlock_max_60Mins = max(Maximum) by Resource, MetricName

加载数据

监视过去一小时内的数据加载。

AzureMetrics
| where ResourceProvider == "MICROSOFT.SQL"
| where TimeGenerated >= ago(60min)
| where MetricName in ('log_write_percent')
| parse _ResourceId with * "/microsoft.sql/servers/" Resource// subtract Resource name for _ResourceId
| summarize Log_Maximum_last60mins = max(Maximum), Log_Minimum_last60mins = min(Minimum), Log_Average_last60mins = avg(Average) by Resource, MetricName

P2S 连接计数

过去 30 天的活动 P2S 连接计数。

AzureMetrics 
| where TimeGenerated > ago(30d)
| where MetricName == "P2SConnectionCount"
| summarize by Maximum, bin(TimeGenerated,1h), Resource
| render timechart

P2S 带宽利用率

过去 12 小时的平均 P2S 带宽利用率(以位/秒为单位)。

AzureMetrics
| where TimeGenerated > ago(24h)
| where MetricName == "P2SBandwidth" 
| summarize by Average, bin(TimeGenerated, 1h), Resource
| render timechart

网关吞吐量

聚合网关吞吐量(以字节/秒为单位)。

AzureMetrics 
| where TimeGenerated > ago(24h)
| where MetricName == "AverageBandwidth"
| summarize by Average, bin(TimeGenerated, 1h), Resource
| render timechart

显示 AzureMetrics 表中的日志

列出 AzureMetrics 表中按时间排序的最新日志(最新日志先列出)。

AzureMetrics
| top 10 by TimeGenerated

显示 AzureMetrics 表中的日志

列出 AzureMetrics 表中按时间排序的最新日志(最新日志先列出)。

AzureMetrics
| top 10 by TimeGenerated

群集可用性 (KeepAlive)

显示过去一小时内的群集可用性。

// To create an alert for this query, click '+ New alert rule'
AzureMetrics 
| where ResourceProvider == "MICROSOFT.KUSTO"
| where TimeGenerated > ago(1d)
| where MetricName == "KeepAlive"
| parse _ResourceId with * "providers/microsoft.kusto/clusters/" cluster_name // Get the cluster name from the ResourceId string
| summarize heartbeat_count = count() by bin(TimeGenerated, 30m), cluster_name // bin is used to set the time grain to 30 minutes
| extend alive=iff(heartbeat_count > 0, true, false)
| sort by TimeGenerated asc // sort the results by time (ascending order)