Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if Tabular variable is empty in KQL

I have a dashboard populated with a number of Kusto KQL Queries.

Sometimes, my query below returns zero results (for instance if by miracle, there are no failures in the last 24 hours).

//my dashboard query 
let failureResults = exceptions | where blahblahblah;
failureResults;

When there are no items that match the filters, my dashboard is filled with

'The query returned no Results'.

How could I go about checking if this variable is null and then doing a different op? For instance, if it's null, then I would just issue a print "No Failures for today, awesome!"; instead.

I have tried iff() statements and isempty(failures| distinct Outcome) and the like, but to no avail. For example, here is another one which didn't work:

failures | project column_ifexists(tostring(Outcome),"No failures where reported!")
like image 683
FoxDeploy Avatar asked Sep 06 '25 23:09

FoxDeploy


1 Answers

Well... Kind of...

let p_threshold = ... ;// set value
let failureResults = datatable(exception_id:int,exception_val:int,exception_text:string)[1,100,"Hello" ,2,200,"World"];
failureResults
| where exception_val > p_threshold
| as t1
| union kind=outer (print msg = 'No Failures for today, awesome!' | where toscalar(t1 | take 1 | count) == 0)
| project-reorder msg

let p_threshold = 0;

msg exception_id exception_val exception_text
1 100 Hello
2 200 World

let p_threshold = 300;

msg exception_id exception_val exception_text
No Failures for today, awesome!

Fiddle

like image 148
David דודו Markovitz Avatar answered Sep 11 '25 01:09

David דודו Markovitz