Skip to content

Instantly share code, notes, and snippets.

@leafo
Created January 17, 2018 05:58
Show Gist options
  • Save leafo/4f812a03968a0c096c64f5a3841ae62a to your computer and use it in GitHub Desktop.
Save leafo/4f812a03968a0c096c64f5a3841ae62a to your computer and use it in GitHub Desktop.
SELECT
$__time(dd),
coalesce((select sum(count) from keys2 where machine_id = md and time >= dd and time <= dd + $interval::"interval"), 0) as value,
'machine ' || md as metric
FROM
generate_series($__timeFrom() at time zone 'utc', $__timeTo() at time zone 'utc', $interval::"interval") dd,
generate_series(1,4) md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment