Time-binned maximum elapsed query



I’d like to do the following (from within Grafana, but that’s not really relevant): get the “elapsed” (time gaps) between values within a time range, then group those into 1-h intervals, and get the max time-gap within each interval. I think I’ve constructed the query correctly, but i’m getting ERR: aggregate function required inside the call to elapsed. Am I doing something obviously wrong?

select max("elapsed") from 
   SELECT elapsed("value",1m) from "mymetric" 
   WHERE ("site" = 'site-name') 
   AND time >= 1515489833447ms 
   AND time <= 1517309498470ms
GROUP BY time(1h)