我试图用AKS集群的一些特定数据创建一个自定义仪表板。我想做的是组装一个仪表板,其中包含每个选定的控制器和节点的RAM和CPU使用情况的图形,并在可能的情况下每个Pod重新启动次数。如何使用控制器的平均资源使用量创建自定义图?
答案 0 :(得分:0)
您可以单击Azure门户中AKS群集刀片左侧的“日志”链接(请先单击“洞察”以确保启用了洞察-如果确定,您将看到与图表接近的图表否则,您会看到入职说明)。
使用以下查询来绘制给定控制器中所有容器的CPU利用率(95%tile):
let endDateTime = now();
let startDateTime = ago(14d);
let trendBinSize = 1d;
let capacityCounterName = 'cpuLimitNanoCores';
let usageCounterName = 'cpuUsageNanoCores';
let clusterName = 'coin-test-i';
let controllerName = 'kube-svc-redirect';
KubePodInventory
| where TimeGenerated < endDateTime
| where TimeGenerated >= startDateTime
| where ClusterName == clusterName
| where ControllerName == controllerName
| extend InstanceName = strcat(ClusterId, '/', ContainerName),
ContainerName = strcat(controllerName, '/', tostring(split(ContainerName, '/')[1]))
| distinct Computer, InstanceName, ContainerName
| join hint.strategy=shuffle (
Perf
| where TimeGenerated < endDateTime
| where TimeGenerated >= startDateTime
| where ObjectName == 'K8SContainer'
| where CounterName == capacityCounterName
| summarize LimitValue = max(CounterValue) by Computer, InstanceName, bin(TimeGenerated, trendBinSize)
| project Computer, InstanceName, LimitStartTime = TimeGenerated, LimitEndTime = TimeGenerated + trendBinSize, LimitValue
) on Computer, InstanceName
| join kind=inner hint.strategy=shuffle (
Perf
| where TimeGenerated < endDateTime + trendBinSize
| where TimeGenerated >= startDateTime - trendBinSize
| where ObjectName == 'K8SContainer'
| where CounterName == usageCounterName
| project Computer, InstanceName, UsageValue = CounterValue, TimeGenerated
) on Computer, InstanceName
| where TimeGenerated >= LimitStartTime and TimeGenerated < LimitEndTime
| project Computer, ContainerName, TimeGenerated, UsagePercent = UsageValue * 100.0 / LimitValue
| summarize P95 = percentile(UsagePercent, 95) by bin(TimeGenerated, trendBinSize) , ContainerName
| render timechart
用所需的名称替换集群名称和控制器名称。您还可以使用开始/结束时间参数,箱尺寸,最大/最小/平均来代替95%的瓷砖。
对于内存指标,将指标名称替换为:
let capacityCounterName = 'memoryLimitBytes';
let usageCounterName = 'memoryRssBytes';