Gruop by, mysql timeseries with unix timestamp column?

Hi! Going a bit crazy here trying to get some kind of group by $__interval_ms going for my mysql timeseries query.
How do I add a group by here, using the $__interval_ms to get the proper grouping for the resolution in the graph?

SELECT shortTime as time,
cpu as value,
‘RKBOX CPU’ as metric
FROM nibejson
WHERE $__unixEpochFilter(shortTime)
ORDER by time ASC

I managed to do this, but is there an easier / more correct way? Is avg ok for the grouping?

$__unixEpochGroup(shortTime,’$__interval’) as time_sec,
avg(cpu) as value,
‘cpu’ as metric
FROM nibejson
WHERE $__unixEpochFilter(shortTime)
GROUP BY 1, ‘cpu’