K6 grafana dashboard RPS query

Hey all. I have been using the K6 grafana dashboard created a few years ago by user dcadwallader found here:

Now, this is a good dashboard and saved us a ton of time in setting one up, but one thing that has been bothering me is the “XXX per second” widgets. Both RPS and Checks per second are a misrepresentation as neither actually shows “per second” but rather “per arbitrary time window depending on how narrow your tie range is”.

Initially I just changed these to GROUP BY time(1s) but the grafana page performance is pretty terrible while attempting to render that.

In the end, a subquery worked:
SELECT mean(rps) FROM (select sum("value") as rps FROM "http_reqs" WHERE $timeFilter GROUP BY time(1s)) WHERE $timeFilter GROUP BY time($__interval) fill(none)

SELECT mean(cps) FROM (select sum("value") as cps FROM "checks" WHERE $timeFilter GROUP BY time(1s)) WHERE $timeFilter GROUP BY time($__interval), "check" fill(none)

If you want to know actual xPS for any time range I suggest these queries. Note, however, that if you use the “total” in the legend, this number won’t be accurate as the total count has been abstracted by averaging these.

Hi, welcome to the forum, and thanks for your contribution!

You’re right that the more appropriate name for these panels would be “XXX per interval” :slight_smile:

Can you provide a before and after screenshot of this change? I setup a panel with your new queries, but I see the same values “per second” when hovering over both old and new panels.

I think the GROUP BY time(1s) subquery would still cause performance issues with large amounts of data, though, since you’d be aggregating by 1s regardless of the chosen time range. Though InfluxDB might optimize this, not sure.