使用天蓝色日志分析为AKS pod重新启动创建警报 [英] Creating alerts with azure log analytics for AKS pod restarts
问题描述
您好,
我正在尝试使用以下查询在特定名称空间中重新启动pod超过指定值时创建警报条件
I am trying to create alert conditions if the pod restart in a particular name space exceed a specified value, using the following query
推荐答案
嗨RevanthReddy,
Hi RevanthReddy,
我看到你的实际要求是在特定的命名空间中获取pod重启计数,所以我认为下面的查询更适用于。
I see that your actual requirement is to get pod restart count in a particular namespace so I think below query is more applicable one.
KubePodInventory| where Namespace == "app-space"| where ClusterName == "my-cluster"| where Name == "xxxxxxxxxxxxxxxxx"| summarize AggregatedValue = count(PodRestartCount) by Name, bin(TimeGenerated, 30m)
但如果您仍在寻找PodCreationTimeStamp的查询,请随时使用以下查询。
But if you are still looking for query with PodCreationTimeStamp then feel free to use below query.
KubePodInventory| where Namespace == "app-space"| where ClusterName == "my-cluster"| where Name == "xxxxxxxxxxxxxxxxx"| summarize AggregatedValue = count(PodCreationTimeStamp) by Name, bin(TimeGenerated, 30m)
注意:在您的情况下,上述两个查询都会产生类似的输出,即如果您使用状态集,则pod名称是静态的。
Note: Both the above queries would result similar output in your case i.e., if pod names are static since you use a statefulset.
要创建提醒,您可以 可能必须转到Azure门户 - > YOURLOGANALYTICSWORKSPACE - >监控磁贴 - >提醒 - >经理警报规则 - >新警报规则 - >添加条件 - >自定义日志搜索 - >在"搜索查询"部分下粘贴上述任何查询
- >在"警报逻辑"部分的"阈值"参数下键入"2" - >点击"完成" - >在"操作组"部分下,选择现有操作组或创建新操作组,如以下查询中所述 - >更新'提醒
详细信息' - >点击"创建提醒规则"。
And to create an alert, you may have to go to Azure portal -> YOURLOGANALYTICSWORKSPACE -> Monitoring tile -> Alerts -> Manager alert rules -> New alert rule -> Add condition -> Custom log search -> Paste any of the above queries under 'Search query' section -> Type '2' under 'Threshold value' parameter of 'Alert logic' section -> Click 'Done' -> Under 'Action Groups' section, select existing action group or create a new one as explained in the below query -> Update 'Alert Details' -> Click on 'Create alert rule'.
https://docs.microsoft.com/en-us/azure/azure-monitor/平台/行动小组
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/action-groups
希望这会有所帮助!!干杯!!
Hope this helps!! Cheers!!
注意:如果您认为您的问题已被解答,请点击"标记为答案",如果只是帮助点击"投票为有用"。
这对阅读此论坛帖子的其他社区成员有益。
这篇关于使用天蓝色日志分析为AKS pod重新启动创建警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!