如果事件计数大于 X,则 Azure 日志分析查询显示计算机
Azure log analytics query to display computers if event count bigger than X
我过去几个小时试图构建 shows/list 计算机的查询,这些计算机已生成超过 10 个具有特定 ID 的事件。
例如,查询列出所有发生事件 2222 的计算机,但我希望查询仅在报告了例如过去 48 小时内超过 10 个相同 ID 的事件时才列出计算机。如果 none 计算机报告了超过 10 个特定 ID 的事件,则结果为空。
Event | where Source contains "service" | where EventID == 2222
显示结果的计算机发生了事件 2222 以及发生了多少次,但如果计数大于 10 时仍然缺少显示结果的示例。
Event
| where Source contains "service" | where EventID == 2222
| summarize count() by Computer
这背后的逻辑是创建某种警报。单个事件并不单独重要,但如果它发生得更多,那么它就开始变得重要了。有什么建议吗?
终于通过这个工作了:
Event
| where Source contains "service" | where EventID == 2222
| summarize count() by Computer
| where count_ > 10
干得好。但是我们通常给它一个 meaningful name
而不是像 count_
.
这样的自动生成的名称
您可以在 summarize
句子中添加一个有意义的名称,例如 summarize TotalCount=count() by Computer
。
完整查询如下:
Event
| where Source contains "service" | where EventID == 2222
| summarize TotalCount=count() by Computer
| where TotalCount > 10
结果:
我过去几个小时试图构建 shows/list 计算机的查询,这些计算机已生成超过 10 个具有特定 ID 的事件。 例如,查询列出所有发生事件 2222 的计算机,但我希望查询仅在报告了例如过去 48 小时内超过 10 个相同 ID 的事件时才列出计算机。如果 none 计算机报告了超过 10 个特定 ID 的事件,则结果为空。
Event | where Source contains "service" | where EventID == 2222
显示结果的计算机发生了事件 2222 以及发生了多少次,但如果计数大于 10 时仍然缺少显示结果的示例。
Event
| where Source contains "service" | where EventID == 2222
| summarize count() by Computer
这背后的逻辑是创建某种警报。单个事件并不单独重要,但如果它发生得更多,那么它就开始变得重要了。有什么建议吗?
终于通过这个工作了:
Event
| where Source contains "service" | where EventID == 2222
| summarize count() by Computer
| where count_ > 10
干得好。但是我们通常给它一个 meaningful name
而不是像 count_
.
您可以在 summarize
句子中添加一个有意义的名称,例如 summarize TotalCount=count() by Computer
。
完整查询如下:
Event
| where Source contains "service" | where EventID == 2222
| summarize TotalCount=count() by Computer
| where TotalCount > 10
结果: