When defining and executing a saved function in Log Analytics as follows, I can see results:
let cfd = () {
let TimeSpanGranularity = 5m;
let MinimumEventsInTimeSpan = 500;
let ErrorRatioThreshold = 0.9;
let TimeSpanTraces = allTraces
| where timestamp > ago(TimeSpanGranularity)
| parse message with * ") " EventText
| parse EventText with EventName ":" *
| extend Event=coalesce(EventName,EventText,message)
| where severityLevel >= 1;
let ShouldFireData = TimeSpanTraces
| summarize ErrorOrAboveCount=todecimal(sumif(itemCount, severityLevel>=3)), TotalEventCount=todecimal(sum(itemCount))
| extend ErrorRatioThreshold
| extend ErrorRatio=100.0*ErrorOrAboveCount/TotalEventCount
| project FireAlert = ErrorRatio>=ErrorRatioThreshold and TotalEventCount>=MinimumEventsInTimeSpan;
let ShouldFire = toscalar(ShouldFireData);
TimeSpanTraces
| where ShouldFire == true and severityLevel >=3;
};
cfd();
However, after saving the function, and attempting to invoke the saved function as follows:
cfd()
I am seeing the following error:
"Body of the callable expression cannot be empty"
I have spent way too much time trying to get this to work.. Any ideas on what I am doing wrong?