根据变量在 Kusto 查询中设置输入 table 名称?

Setting input table name in Kusto query depending on variable?

总结

根据输入参数,我想对 Kusto 查询使用 table1 或 table2。

背景

我有一个 Kusto table,例如"table_all",带有网络服务器访问日志,所有客户流量都有很多行。目前我正在添加第二个 table,其中包含每个客户每分钟或每小时的点击次数。 ("table_aggregated")

为了形象化这一点,我将 Grafana 与 Kusto 结合使用来绘制每个客户随时间的点击次数。 Grafana 仪表板包含类似

的查询
table_all
| where $__timeFilter(event_timestamp)
| where customer == "$customer"
| summarize count(), bin(event_timestamp, $__interval)

它可以很好地绘制特定客户随时间的点击次数。

根据 Grafana 的时间范围视图,我想使用 table_full 或 table_aggregated 作为查询的输入。

当在 Grafana 中选择一个完整的月份或更长时间时,$__interval 设置为 1 小时,我可以利用 table 和聚合数据。

有没有办法根据 $__interval 的值构建输入 table 名称?

您可以使用 union 来实现:https://docs.microsoft.com/en-us/azure/kusto/query/unionoperator

例如:

let T1 = range x from 1 to 3 step 1;
let T2 = range x from 11 to 13 step 1;
let _interval = 7h;
union
(T1 | where _interval < 5h),
(T2 | where _interval >= 5h)

请问return号码11,12,13.

如果您将 7h 替换为 3h,它将 return 数字 1,2,3