Forum Discussion
DurgaPrasad635
Jul 11, 2022Copper Contributor
Need help with log analytics query for API failure percentage
Hi, I am trying to get API management service failure percentage in Log analytics, but not getting anywhere. Can anyone please help in this ? something like below I tried but no luck, still l...
- Jul 12, 2022
Yes, just add this. I did add a filter so only entries above 1% are shown (in the test data I get a lot below that...you may want all of them or another number)
let totalreq = toscalar(AppRequests | count); AppRequests | summarize failure_percentage =countif(Success=='False') / todouble(totalreq) * 100 by OperationName | where failure_percentage > 1 | render barchart
Clive_Watson
Jul 12, 2022Bronze Contributor
You can try this, the trick is to use the toscalar() function: toscalar() - Azure Data Explorer | Microsoft Docs
let totalreq = toscalar(AppRequests
| count);
AppRequests
| summarize failure_percentage =countif(Success=='False') / todouble(totalreq) * 100 , success_percentage =countif(Success=='True') / todouble(totalreq) * 100I did success and failure, just to make sure they added up to 100% - remove the success part if not needed
- DurgaPrasad635Jul 12, 2022Copper Contributor
Thanks this helped me!
Is it possible to get OperatonName which is failed ? just tryint to create a dashboard.
Thanks
- Clive_WatsonJul 12, 2022Bronze Contributor
Yes, just add this. I did add a filter so only entries above 1% are shown (in the test data I get a lot below that...you may want all of them or another number)
let totalreq = toscalar(AppRequests | count); AppRequests | summarize failure_percentage =countif(Success=='False') / todouble(totalreq) * 100 by OperationName | where failure_percentage > 1 | render barchart