2

有没有办法使用 kusto 语言以编程方式检查日志分析中是否存在表?

例如,假设我想检查工作区是否包含 VMConnection 表,例如:

IF OBJECT_ID('*objectName*', 'U') IS NOT NULL 

或者

IF (EXISTS (SELECT * 
                 FROM INFORMATION_SCHEMA.TABLES 
                 WHERE TABLE_SCHEMA = 'TheSchema' 
                 AND  TABLE_NAME = 'TheTable'))
BEGIN
    --Do Stuff
END
4

1 回答 1

8

也许,您可以使用下一个技术来检查是否存在非空表:

let hasNonEmptyTable = (T:string) 
{ 
   toscalar( union isfuzzy=true ( table(T) | count as Count ), (print Count=0) | summarize sum(Count) ) > 0
};
let TableName = 'StormEvents';
print Table=TableName, IsPresent=iif(hasNonEmptyTable(TableName), "Table present", "Table not preset")

您可以尝试使用https://dataexplorer.azure.com/clusters/help/在线运行它

于 2019-04-08T19:48:46.303 回答