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 learning
let totalreq = AppRequests
| count
| project Count;
AppRequests
| where Success == false
| project OperationName, failure_percentage = counto / totalreq * 100
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_WatsonBronze 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) * 100
I did success and failure, just to make sure they added up to 100% - remove the success part if not needed
- DurgaPrasad635Copper Contributor
Thanks this helped me!
Is it possible to get OperatonName which is failed ? just tryint to create a dashboard.
Thanks
- Clive_WatsonBronze 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