查询 Azure Log Analytics 中的多个表

Pet*_*ter 8 azure azure-log-analytics kql azure-data-explorer

我正在查看 Web 应用程序的 Azure 日志分析,并且我有多个包含数据的开箱即用“表”:traces, requests,exceptions等。

我可以构造一个对多个表中的数据运行的查询吗?我不想加入来自不同来源的数据,我只想连接/交错它,所以我可以寻找例如“所有痕迹包含字符串‘SQL’的

从理论上讲,类似于:

traces, exceptions
| where * contains "SQL"
| order by timestamp desc
| limit 100
Run Code Online (Sandbox Code Playgroud)

这可能吗?

Car*_*cia 10

您可以使用union。我发现非常有用的是将所有表与union *. 例如:

union *
| where * contains "SQL"
Run Code Online (Sandbox Code Playgroud)

这样您将在所有表中搜索包含 SQL 的任何列

如果您想要特定的表(例如tracesexceptions):

traces 
| union exceptions
| where * contains "SQL"
Run Code Online (Sandbox Code Playgroud)

[编辑] 还有一个较新的命令,具有相同的结果(与前一个命令没有优点或缺点)

search in (table1, table2, table3) "SQL"
| where timestamp > ago(6h)
Run Code Online (Sandbox Code Playgroud)