I am trying to make a continuous query (CQ) work to match an SELECT INTO
query that works correctly. Specifically, I’m trying to make a CQ to accurately calculate the send and recv bandwidths from the net
input in such a way that aggregate queries/visualizations don’t change based in the size of the aggregation window size.
To backfill the data, this SELECT
works perfectly (formatted for readability):
SELECT
8*non_negative_derivative(max("bytes_recv"),1s) AS rx_rate_bps
,8*non_negative_derivative(max("bytes_sent"),1s) AS tx_rate_bps
INTO "net_bandwidth_cq"
FROM "net"
WHERE time > now() - 5d
AND interface = 'eth0'
GROUP BY time(1s), host, *
The matching CQ that I make to keep this up to date is done this way:
CREATE CONTINUOUS QUERY "cq_net_bandwidth"
ON telegraf
BEGIN
SELECT
8*non_negative_derivative(max("bytes_recv"),1s) AS rx_rate_bps
,8*non_negative_derivative(max("bytes_sent"),1s) AS tx_rate_bps
INTO "net_bandwidth_cq"
FROM "net"
WHERE interface = "eth0"
GROUP BY time(1s), host, *
END
This seems to create ok, and CQ logging (in syslog) seems to indicate that it does run successfully, but it definitely does not add to the same measurement that was created with the SELECT INTO
above, nor can I figure out where the CQ results end up.
Here is how it registers itself:
> SHOW CONTINUOUS QUERIES
name: _internal
name query
---- -----
name: telegraf
name query
---- -----
cq_net_bandwidth CREATE CONTINUOUS QUERY cq_net_bandwidth ON telegraf BEGIN SELECT 8 * non_negative_derivative(max(bytes_recv), 1s) AS rx_rate_bps, 8 * non_negative_derivative(max(bytes_sent), 1s) AS tx_rate_bps INTO telegraf.autogen.net_bandwidth_cq FROM telegraf.autogen.net WHERE interface = eth0 GROUP BY time(1s), host, * END
What am I doing wrong here? Why doesn’t this work?