azureazure-functionsazure-monitoring

Kusto query for generating Azure function success and failure count line graph


I need to create a time series chart showing the total successes and failures for an Azure function app. I couldn't find any in-built metric for function app that shows success and failures for a trigger function so I've written a Kusto query that gives me this information in a tabular manner. Here is the query-

requests
| project
    timestamp,
    operation_Name,
    success,
    resultCode,
    duration,
    operation_Id,
    cloud_RoleName,
    invocationId=customDimensions['InvocationId']
| where timestamp > ago(30d)
| where cloud_RoleName =~ 'my-function-app-site' and operation_Name =~ 'FunctionName'

This query gives me the information in a table however I'm interested in a graph showing the count of successes and failures on a hourly interval. I'm not very familiar with Kusto queries, so could someone here help me with the query please?


Solution

  • You can use the below KQL query to create a time series chart showing the total success and failures for an Azure function app

    requests
    | project
        timestamp,
        operation_Name,
        success,
        resultCode,
        duration,
        operation_Id,
        cloud_RoleName,
        invocationId=customDimensions['InvocationId']
    | where timestamp > ago(30d)
    | where cloud_RoleName =~ 'function app name' and operation_Name =~ 'Function name'
    | extend hour = bin(timestamp, 1h) // Create hourly intervals
    | summarize
        SuccessCount = sum(toint(success == 'True')),
        FailureCount = sum(toint(success == 'False'))
        by hour
    | project
        hour,
        SuccessCount,
        FailureCount
    | order by hour asc
    | render timechart
    

    Output

    enter image description here

    In my case there is no failure request, so I am getting zero records.