gpt4 book ai didi

azure - 如何创建当许多机器中的一台无法报告心跳时触发的警报?

转载 作者:行者123 更新时间:2023-12-02 23:35:45 25 4
gpt4 key购买 nike

总的来说,我正在尝试使用“心跳”表设置一个 azure 警报,以便在计算机出现故障时向我发送电子邮件。

假设我的 Azure 订阅中有 5 台计算机,它们每分钟向名为 Heartbeat 的表报告一次,所以它看起来像这样:

Table Example

目前,我可以查询“Heartbeat | where Computer == 'computer-name'| where TimeGeneerated > ago(5m)”并找出一台计算机在过去 5 分钟内未报告且已关闭的时间 ( thank you to this great article for that query )。

我对任何查询语言都不是很有经验,所以我想知道是否可以有 1 个查询来检查是否有任何计算机在过去 5-10 分钟内停止发送日志,并且这样就会下降。 Azure 使用 KQL 或 Kusto 查询语言进行查询,上面的链接中有文档。

感谢您的帮助

最佳答案

一个选项是计算每台计算机的最大报告时间,然后筛选出最大报告时间早于 5 分钟前的计算机:

let all_computers_lookback = 12h
;
let monitor_looback = 5m
;
Heartbeat
| where TimeGenerated > ago(all_computers_lookback)
| summarize last_reported = max(TimeGenerated) by computer
| where last_reported < ago(monitor_looback)

另一种选择:

  • 第一部分创建最近(例如 12 小时)至少报告过一次的所有计算机的“ list ”。
  • 第二部分查找最近(例如 5 分钟)至少报告过一次的所有计算机
  • 第三部分也是最后一部分找出两者之间的差异(即过去 5 分钟内未报告的所有计算机)

注意:如果您拥有超过 1M 台计算机,则可以使用 join 运算符而不是 in() 运算符

let all_computers_lookback = 12h
;
let monitor_looback = 5m
;
let all_computers =
Heartbeat
| where TimeGenerated > ago(all_computers_lookback)
| distinct computer
;
let reporting_computers =
Heartbeat
| where TimeGenerated > ago(monitor_looback)
| distinct computer
;
let non_reporting_computers =
all_computers
| where computer !in(reporting_computers)
;
non_reporting_computers

关于azure - 如何创建当许多机器中的一台无法报告心跳时触发的警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72309970/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com