Search code examples
azure-application-insightskql

How to render average duration of events falling on the same time instead of their summary in App Insights?


I have telemetry for builds where some builds were started at the same time. Here is the query and the resulting graph:

AllBuilds
| project buildDef, startTime, result, runSeconds, runDuration, buildNumber
| where buildDef == 'dayforce-PR-AzureTest'
    and startTime >= todatetime('2021-11-27 04:27')
    and startTime < todatetime('2021-12-03 21:34')
    and result == 'succeeded'
| project startTime, minutes = runSeconds / 60, runDuration, buildNumber
| render columnchart

enter image description here

The spikes represent the builds that fell on the same time. Their build times are added, which is not what I want. I would like to average them instead. Ideally, I prefer keeping both values, but since they fall on the same time exactly I am not sure if this is possible.

I tried adding with (accumulate=false), but it does not seem to bear any effect.


Solution

  • If I understand correctly, you could try using the avg() aggregation function:

    AllBuilds
    | where buildDef == 'dayforce-PR-AzureTest'
        and startTime >= todatetime('2021-11-27 04:27')
        and startTime < todatetime('2021-12-03 21:34')
        and result == 'succeeded'
    | summarize avg(runDuration) by bin(startTime, 1h)
    | render timechart