Some time ago I posted an article about how to calculate RPS in Application Insight or KQL (a.k.a. AQL).
Turns out, that query only works under heavy load. By heavy load I mean a kind of traffic that has activity per unit of your bin (per second.)
What I want to do is to draw a graph for a heartbeat. The heartbeat was happening once every few seconds. When I run the query from my previous article it removed all the none active seconds (seconds with 0 activity) and this was the result:
As you can see we do not see the seconds that have no activity and therefore the result is a straight line.
As you probably have guessed we need to first lay down each second with a default value of zero for it’s activity and then feed it with real activity.
The script will look something like this:
let startTime = ago(5m);
| where timestamp > startTime and message startswith "Received Heartbeat"
| order by timestamp
| make-series c=count(itemCount) default=0 on timestamp in range(startTime, now(), 1s)
| mvexpand timestamp, c
| project todatetime(timestamp), toint(c)
| render timechart
which results in the following chart for the exactly same duration:
That is much better now. We have a graph that shows the expected result.
It’s worth mentioning that true RPS cannot be done for the long duration because of too many data points.
Do you know any other/better way of calculating the true and exact RPS?