-- The original timestamp is stored in double12 as UNIX nano
SELECT
(intDiv(intDiv(double12, 1000000000), $interval) * $interval) * 1000 as ts,
double9 as originPort,
sum(_sample_interval) AS events
FROM honeypot_spectrum_events
WHERE
-- Use the indexed timestamp to retrieve rows written between $from and $to + 1 day
timestamp >= toDateTime($from) AND timestamp <= toDateTime($to + 86400) AND
-- Use the original timestamp to retrieve events that occurred between $from and $to
double12 >= ($from * 1000000000) AND double12 <= ($to * 1000000000)
GROUP BY ts, originPort ORDER BY ts
-- The original timestamp is stored in double12 as UNIX nano
SELECT
(intDiv(intDiv(double12, 1000000000), $interval) * $interval) * 1000 as ts,
double9 as originPort,
sum(_sample_interval) AS events
FROM honeypot_spectrum_events
WHERE
-- Use the indexed timestamp to retrieve rows written between $from and $to + 1 day
timestamp >= toDateTime($from) AND timestamp <= toDateTime($to + 86400) AND
-- Use the original timestamp to retrieve events that occurred between $from and $to
double12 >= ($from * 1000000000) AND double12 <= ($to * 1000000000)
GROUP BY ts, originPort ORDER BY ts