Search code examples
azureazure-web-app-serviceazure-log-analyticsappinsights

Azure Dasboards alert based on percentage


In Azure dashboards, is there any way we can trigger alerts based on percentage instead of counts?.. Example if total total failures in 20 minutes is 20%, then trigger alert than just cheking the counts of the failures? Here setting the count is not meeting our requirement and looking a solution based on the Percentage of occurance.


Solution

  • Based on the above shared requirement , we have created the custom Kusto query to calculate the percentage of failure requests & to trigger an email alert notification if the failure requests percentage > 20% for a particular web app & also projecting the output of the Kusto query to the dashboard as well.

    Here is the custom Kusto query :

    requests
    | where timestamp >= ago(6h)
    | project success, ['id'], resultCode, appName
    | summarize failedtotal = countif(success == 'False'), total= count()
    | project  failurepercentage = (100 * (failedtotal) / (total))
    | summarize totalouputrows=countif(failurepercentage>20) by failurepercentage
    

    Use the New alert rule option in the log analytics space to create a custom alert & using the above query as signal as shown in below picture.

    enter image description here

    Use the Pin to dashboard option in the log analytics work space to project the output of the custom Kusto query & create the dashboard accordingly.

    enter image description here

    Here is the sample image of the alert rule that was created using the above query.

    enter image description here

    Here is the sample email output & Kusto query output projected to dashboard triggered by above alert rule.

    enter image description here