Ind*_*dar 1 azure-log-analytics kql azure-data-explorer
目前,我有一个返回Union3 个表(共 13 行)的查询。所有 3 个表都具有相同的列集。
let bytes_to_gb =
(1024 * 1024 * 1024)
;
let tab_cpu =
performanceCounters
| where category == "Processor" and counter == "% Processor Time" and instance == "_Total"
| where ...
| summarize timestamp = max(timestamp), value = avg(value) by host_name = cloud_RoleInstance, host_type = "WXYZ", counter_name = "%CPU", threshold = 90
;
let tab_memory =
performanceCounters
| where category == "Memory" and counter == "Available Bytes"
| where ...
| summarize timestamp = max(timestamp), value = avg(value / bytes_to_gb) by host_name = cloud_RoleInstance, host_type = "ZYXW", counter_name = "Available Memory (GB)", threshold = 10
;
let tab_exceptions =
exceptions
| where ...
| summarize timestamp = max(timestamp), value = (count(itemCount) * 1.0) by host_name = "Exceptions", host_type = "Web", counter_name = "Exception", threshold = 10
| where value >= 10
union
tab_cpu, // 6 rows
tab_memory, // 6 rows
tab_exceptions // 1 row
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是-包括结果tab_cpu和tab_memory ONLY,如果tab_exceptions有行。
这就是我在 SQL Query 中所做的,但没有得到正确的 KQL 解决方案。
IF EXISTS (SELECT * FROM tab_exceptions WHERE ...)
SELECT * FROM tab_cpu WHERE ...;
UNION
SELECT * FROM tab_memory WHERE ...
UNION
SELECT * FROM tab_exceptions WHERE ...
ELSE
...
Run Code Online (Sandbox Code Playgroud)
您可以union以类似于以下示例的方式使用运算符:
let T1 = range x from 1 to 3 step 1; // for the other case, replace with: let T1 = datatable(x:long)[];
let T2 = range x from 4 to 6 step 1;
let T3 = range x from 7 to 9 step 1;
let T1_has_rows = toscalar(T1 | summarize count() > 0);
union
(T1 | where T1_has_rows == false),
(union T1, T2, T3 | where T1_has_rows == true)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
605 次 |
| 最近记录: |