如何从Azure日志分析中获得按命名空间筛选并按服务分组的CPU使用率和内存使用率图



我试图获取Azure上托管的应用程序的CPU使用率和内存使用率。该应用程序有多个服务,我想获得一段时间内按应用程序服务(命名空间(分组的平均CPU使用率和内存使用率。

这是我认为有效的方法,但随着时间的推移,似乎没有给我数据。

KubePodInventory
| where Namespace contains 'namespace'
| extend InstanceName = strcat(ClusterId, '/', ContainerName)
| join Perf on InstanceName
| where ObjectName == 'K8SContainer' and CounterName == 'cpuUsageNanoCores'
| summarize CPU=avg(CounterValue)/1000000000 by LogTime=bin(TimeGenerated, 1m), ServiceName

提前感谢您在这方面的帮助。

我想我已经成功了。这是我得到的。

Perf
| where ObjectName == 'K8SContainer' and CounterName == 'cpuUsageNanoCores'
| summarize CPU=avg(CounterValue)/1000000000 by LogTime=bin(TimeGenerated, 1m), InstanceName
| lookup (KubePodInventory
| where Namespace=='namespace'
| extend InstanceName = strcat(ClusterId, '/', ContainerName)
| summarize by Namespace, InstanceName, ServiceName) on InstanceName
| where Namespace == 'namespace'
| project LogTime, ServiceName, CPU
| where ServiceName contains 'servicenaame'

最新更新