如何访问 kusto/Azure 应用程序洞察中子查询中的外部列?

Dar*_*han 7 azure azure-application-insights azure-data-explorer

我尝试使用 Kusto 在 Azure 应用程序见解中简单地运行子查询,以便我可以从显示为一个的两个表中获取一些信息。

我正在尝试的查询是

table1
| extend progressLog = toscalar(
    table2 
    | where common_Id == table1.common_Id // errors saying Ensure that expression: table1.common_Id is indeed a simple name
    | summarize makelist(stringColumn) 
)
Run Code Online (Sandbox Code Playgroud)

我尝试给这个 id 起别名,甚至连接两个表,如下所示:

requests
| extend aliased_id = common_Id
| join traces on operation_Id, $left.operation_Id == $right.operation_Id
| extend test_id = operation_Id 
| extend progressLog = toscalar(
    traces 
    | where operation_Id == aliased_id // Failed to resolve column or scalar expression named 'aliased_id'
    | summarize makelist(message) 
)
Run Code Online (Sandbox Code Playgroud)

无法解析名为“aliased_id”的列或标量表达式。

我只是尝试执行与 T-SQL 查询等效的操作:

SELECT 
    ... ,
    STRING_AGG(table2.stringColumn, ',')
FROM
    table1 
INNER JOIN 
    table2 
    ON table1.common_Id = table2.common_Id
GROUP BY 
    table.<props>
Run Code Online (Sandbox Code Playgroud)

我的主要问题是 - 如何在子查询中引用 kusto 语言中的“common_Id”

小智 8

请查看下一个查询是否提供您要查找的内容。如果没有,请使用数据表共享示例输入(如下所示)和预期输出:

let requests = datatable(common_Id:string, operation_Id:string)
[
    "A", "X", 
    "B", "Y", 
    "C", "Z"
]; 
let traces = datatable(operation_Id:string, message:string)
[
    "X", "m1", 
    "X", "m2",
    "Y", "m3"
]; 
let messagesByOperationId = traces | summarize makelist(message) by operation_Id;
requests 
| join kind=leftouter messagesByOperationId on operation_Id
| project common_Id, operation_Id, progressLog = list_message
Run Code Online (Sandbox Code Playgroud)