使用 "workspace" 的 App Insights 无法使用具有时间范围的 Log Analytics KQL

Log Analytics KQL with Time Range does not work from App Insights using "workspace"

我有一个 Log Analytics KQL 如下 Custom TableTime Range;它在 Log Analytics.

中运行良好

您可以注意到 Time range = Set in query automatically。


但是当我 运行 来自 App Insights 的相同 KQL 使用 workspace 时,它不会考虑 TimeGenerated 并获取数据时间范围设置在App Insights和returns错误的结果集中!

你可以注意到 时间范围 = 最后 30 分钟 尽管我已经给出 TimeGenerated > ago(365d)!

I have noticed same issue with App Insights KQL running in Log Analytics using app() function!

不确定哪里出了问题或者是限制?

根本原因是在application insights中,它使用timestamp列来表示记录的时间。但在 Log analytics 中,它使用 TimeGenerated 列来表示记录的时间。

因此,当您在 Application insights 中使用 workspace("log-analytics") 和 TimeGenerated > ago(10d) 时,application insights 无法识别 TimeGenerated

截图如下:

遇到这种情况,解决方法是,将TimeGenerated重命名为timestamp,让application insights可以识别。示例查询如下: