【问题标题】:Azure AKS Monitoring - custom dashboard resourcesAzure AKS 监控 - 自定义仪表板资源
【发布时间】:2019-02-07 09:09:46
【问题描述】:

我正在尝试为 AKS 群集创建包含一些特定数据的自定义仪表板。我想做的是组装一个仪表板,其中包含每个选定控制器和节点的 RAM 和 CPU 使用率图表,以及每个 pod 的重启次数(如果可能)。如何使用控制器的平均资源使用情况创建自定义图表?

【问题讨论】:

  • 去吧,有什么问题?
  • 你说得对,它还不够清楚。我稍微修改了一下。
  • 为什么不使用 Azure Container Monitor?它开箱即用。见docs.microsoft.com/en-us/azure/azure-monitor/insights/…
  • 我正在使用它。我想要实现的是制作一个独立的图表,将其添加到自定义仪表板中,其中包含控制器的所有 TREND MAX % (1 BAR = 15M) 值,目前我只能从他们的自定义指标视图中访问。 pasteboard.co/I0c2De6.png

标签: monitoring azure-aks


【解决方案1】:

您可以在 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

将集群名称和控制器名称替换为您想要的名称。您还可以使用开始/结束时间参数、bin 大小、max/min/avg 代替 95th %-tile。

对于内存指标,请将指标名称替换为:

let capacityCounterName = 'memoryLimitBytes';
let usageCounterName = 'memoryRssBytes';

【讨论】:

  • 谢谢 Vitaly,我试试看。
  • 我忘了说,对不起:一旦你的查询显示了你想在仪表板上看到的内容,点击结果右侧上方的“pin”图标,它就会显示出来在您选择的仪表板上
  • 我将 let clusterName = let controllerName = 更改为与我的集群相关的内容,但出现语法错误。无法弄清楚查询中的确切位置。
  • 能否请您发送电子邮件至 askcoin@microsoft.com 并附上您的查询以及 查询 的屏幕截图以及您遇到的 错误得到?我们将能够帮助您修复您的查询语法...有时它真的很偷偷摸摸...单引号在复制粘贴等时更改为其他内容...我再次检查了上面的查询以防万一它似乎工作正常......
  • 是的,已发送!再次感谢。
猜你喜欢
  • 2020-10-23
  • 2022-01-16
  • 2017-01-01
  • 2020-09-19
  • 1970-01-01
  • 2017-04-29
  • 1970-01-01
  • 2022-11-03
  • 2015-03-29
相关资源
最近更新 更多