【问题标题】:Kusto how to use comparison operator with timespanKusto 如何使用带时间跨度的比较运算符
【发布时间】:2021-06-18 20:29:44
【问题描述】:

我需要编写一个查询来查看超过 15 天的结果。我有这段代码,我在其中获取时间跨度格式(15.04:01:02)的 avg_duration。我现在想根据 avg_duration 进行过滤,只返回超过 15 天的结果。

| summarize arg_max(TimeGenerated, *) by ResourceId, RecommendationId, Severity
| order by RecommendationId asc, TimeGenerated asc
| extend duration = iff(RecommendationId == prev(RecommendationId), TimeGenerated - prev(TimeGenerated), 0s)
| summarize avg(duration) by ResourceId, RecommendationId, Severity
| where avg_duration >= "15.0:0:0"

当我在 Log Analytics 中运行此程序时,我收到错误“无法比较时间跨度和长时间类型的值。尝试添加显式强制转换”。有什么想法可以过滤时间跨度吗?

【问题讨论】:

  • 嗨@sspider3,如果有帮助,请接受下面的答案。谢谢。 (请参阅this 了解有关为什么以及如何执行此操作的更多信息)。谢谢!

标签: azure azure-data-explorer kql


【解决方案1】:

代替:

| where avg_duration >= "15.0:0:0"

你应该写

| where avg_duration >= 15d // 注意15d 代表 15 天

详细了解如何编写时间跨度文字here

【讨论】:

  • 成功了,我想我几乎尝试了所有方法,但感谢您的关注。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-05
相关资源
最近更新 更多