使用标记子集对采样进行连续查询

时间:2015-11-06 02:00:06

标签: influxdb

Influxdb 0.9 documentation举一个例子,通过简单地执行GROUP BY time(<some interval>), *

来保留连续查询(CQ)上的所有标签

有没有办法从原始集中保留我可能感兴趣的标记子集?

例如,如果我有measurement_a:标签:tag_1tag_2tag_3和字段:field_1

我希望创建一个从measurement_a中选择的CQ,并插入INTO measurement_cq_a,只需tag_a。语法是什么?

我试过

CREATE CONTINUOUS QUERY measurement_cq_a ON metrics BEGIN SELECT SUM(value) as sum_val, tag_a INTO "measurement_cq_a" FROM "measurement_a" WHERE time > now() - 1h GROUP BY time(5m), tag_a END

但这会导致大量涌入,而且指数超出范围&#34;误差/恐慌。

panic: runtime error: index out of range

goroutine 23 [running]:
github.com/influxdb/influxdb/services/continuous_querier.(*Service).convertRowToPoints(0xc208010310, 0xc210207dd0, 0x21, 0xc21045f3e0, 0x0, 0x0
, 0x0, 0x0, 0x0)
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:349 +0x6ec
github.com/influxdb/influxdb/services/continuous_querier.(*Service).runContinuousQueryAndWriteResult(0xc208010310, 0xc20c5f4240, 0x0, 0x0)
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:287 +0x2f4
github.com/influxdb/influxdb/services/continuous_querier.(*Service).ExecuteContinuousQuery(0xc208010310, 0xc2101b52c0, 0xc210214460, 0x0, 0x0)
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:256 +0xb0f
github.com/influxdb/influxdb/services/continuous_querier.(*Service).runContinuousQueries(0xc208010310)
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:178 +0x32a
github.com/influxdb/influxdb/services/continuous_querier.(*Service).backgroundLoop(0xc208010310)
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:160 +0x1d8
created by github.com/influxdb/influxdb/services/continuous_querier.(*Service).Open
        /root/.gvm/pkgsets/go1.4.2/global/src/github.com/influxdb/influxdb/services/continuous_querier/service.go:87 +0x1ed

我在Influx 0.9.0上测试了这个

1 个答案:

答案 0 :(得分:4)

对于其他人来说,我的愚蠢错误就是这样。

正确的查询运行似乎是: CREATE CONTINUOUS QUERY measurement_cq_a ON metrics BEGIN SELECT SUM(value) as sum_val INTO "measurement_cq_a" FROM "measurement_a" WHERE time > now() - 1h GROUP BY time(5m), tag_a END

我在尝试(错误):

CREATE CONTINUOUS QUERY measurement_cq_a ON metrics BEGIN SELECT SUM(value) as sum_val, **tag_a** INTO "measurement_cq_a" FROM "measurement_a" WHERE time > now() - 1h GROUP BY time(5m), tag_a END

注意:对于想知道的人..由于0.9.0中的错误,我在查询中需要WHERE子句。我认为这是在0.9.1

中修复的