【问题标题】:Query multiple tables in Azure Log Analytics在 Azure Log Analytics 中查询多个表
【发布时间】:2019-10-29 21:52:34
【问题描述】:

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

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

理论上,类似:

traces, exceptions
| where * contains "SQL"
| order by timestamp desc
| limit 100

这可能吗?

【问题讨论】:

标签: azure azure-log-analytics azure-data-explorer kql


【解决方案1】:

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

union *
| where * contains "SQL"

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

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

traces 
| union exceptions
| where * contains "SQL"

【讨论】:

    【解决方案2】:

    您可能还想考虑search 运算符

    search in (exceptions, traces) "SQL"
    | order by timestamp desc 
    | take 100
    

    https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/searchoperator?pivots=azuredataexplorer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-09
      • 2021-12-07
      • 2021-03-20
      相关资源
      最近更新 更多