Aggregating multiple metrics

The total maximum cpu usage of two hosts between two dates.

SELECT max(max(cpu.usage_user FROM bucket WHERE (hostname = 'host_1' or hostname = 'host_2'), 1m) METADATA {hostname: $hostname} BETWEEN "2016-01-16T13:00:24Z" AND "2016-01-17T13:00:24Z"

GROUP BY

Average cpu usage grouped by per host during the last day aggregated per hour.

SELECT avg(cpu.usage_user FROM bucket GROUP BY $hostname USING avg, 1h) AS $hostname.cpu.usage_user LAST 1d

TOP

Show the two VM's that used most CPU (average over the last minute) based on tachyon data.

SELECT caps FROM zone WHERE kstat:name = cpu AND kstat:key = usage AS $kstat:uuid LAST 60s TOP 2 BY avg()

The same with the 1st value above 10

SELECT caps FROM zone WHERE kstat:name = cpu AND kstat:key = usage AS $kstat:uuid LAST 60s TOP 2 BY first_above(10)