Influxdb 0.9 documentation举一个例子,通过简单地执行GROUP BY time(<some interval>), *
有没有办法从原始集中保留我可能感兴趣的标记子集?
例如,如果我有measurement_a
:标签:tag_1
,tag_2
,tag_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上测试了这个
答案 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
中修复的