Influxdb中连续查询忽略where子句? [英] Continuous queries in Influxdb ignoring where clause?

查看:1499
本文介绍了Influxdb中连续查询忽略where子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在pngxdb 0.8.8中我连续查询有点麻烦。
我试图创建一个连续的查询,但似乎where子句被忽略。我知道这里提到的限制: http://influxdb.com/docs /v0.8/api/continuous_queries.html ,但我不认为这是这种情况。



时间序列中的一行将包含这样的数据:

  {hex:06a0b6,squawk:3421, qTR028,lat:99.867630,lon:66.447365validposition:1,altitude:39000,vert_rate: -  64,track:125,validtrack :482,messages:201,seen:219} 

我正在运行的查询作品如下:

  select * from flight_series where time> now() -  30m和flight!〜/ ^ $ /和validtrack = 1和validposition = 1; 

通过它我想要从当前时间开始最后30分钟,检查航班字段不是空格,并且轨道/位置是有效的。
查询返回成功,但是当我将

 添加到filtered_log 

部分忽略where子句。



如何创建连续考虑上述条件的查询?至少,我如何提取一个连续的查询只有有效的轨道/标题设置为1,航班不是空格/空字符串的行?时间限制我可以从查询中消除并转换为分片保留/持续时间。



此外,我可以在连续查询中指定将数据保存到时间 - 系列位于另一个数据库(其中有更宽松的保留/持续时间政策)?



谢谢!



以后编辑:



我使用以下cq设法更贴近我的需要:



< $(pre> select time,sequence_number,altitude,vert_rate,messages,squawk,lon,lat,speed,hex,from current_flights where((flight!〜/ ^ $ /)AND(validtrack = 1))AND(validposition = 1)into flight。[flight]

对于每个飞行,即使是在飞行领域有空白的飞行员也可以进行飞行。系列已建成。



如何指定上述cq生成的系列的保留期限?我可以这样做:

 空格:[
{
name:
retentionPolicy:1h,
shardDuration:30m,
regex:/.*/,
replicationFactor ,
split:1
},
...

这会让我保留1小时,并保留30分钟的时间?



我对这些系列存储的位置感到有些困惑,哪个碎片空间? p>

谢谢!



PS:我的最终目标如下:
有一个窗口最多15-30分钟,所有航班周围,处理一些数据,并在此期间结束丢弃数据,但同时移动/复制到另一个可用于历史目的的长期db /系列。 / p>

解决方案

您不能将时间限制放入连续查询的WHERE子句中。当CQ运行时,服务器将根据需要生成时间限制,并且必须忽略所有其他的时间限制。我怀疑你是否省略了时间限制,WHERE子句的其余部分将会很好。



我不认为0.8中的CQ需要SELECT中的聚合,但是你需要有GROUP BY子句来告诉CQ运行的频率。我不知道你会是GROUP BY,也许航班



你可以指定一个不同的保留政策当写入新的系列,但不是一个新的数据库。在0.8中,系列的保留策略由系列名称上的正则表达式匹配决定。只要您正确选择系列名称,就会进入所需的保留政策。



编辑:新问题的更新


如何指定上述cq生成的系列
的保留期限?


在0.8.x中,系列所属的分片空间控制着保留策略。碎片空间上的正则表达式确定哪个系列属于该分片。碎片空间正则表达式被评估为最新到最旧,这意味着第一个创建的分片空间将是最后一个正则表达式。不幸的是,我知道是否有可能在数据库存在之后创建新的分片空间。有关详细信息,请参阅邮件列表中的此讨论: https://groups.google.com/d/msgid/influxdb/ce3fc641-fbf2-4b39-9ce7-77e65c67ea24%40googlegroups.com


我可以这样做:



空格:[
{
name:flight,
retentionPolicy:1h,
shardDuration:30m,
regex:/.*/,
replicationFactor:1,
split:1
},...这会让我保留1小时,分片时长为30m?




该分片空间的分片持续时间为30分钟,保留数据为1小时,这意味着任何系列只能存在于三个分片,当前的热分片,当前的冷分片和等待删除的分片。



正则表达式是/./,这意味着它将匹配任何系列,而不仅仅是飞行系列。或者/flight../是一个更好的正则表达式,如果你只想要在这个分片空间中由CQ生成的那些系列。


I'm having a bit of a trouble with the continuous queries in influxdb 0.8.8. I'm trying to create a continuous query but it seems that the where clauses are ignored. I'm aware about the restrictions mentioned here: http://influxdb.com/docs/v0.8/api/continuous_queries.html but I don't consider that this would be the case here.

One row in the time series would contain data like this:

{"hex":"06a0b6", "squawk":"3421", "flight":"QTR028  ", "lat":99.867630, "lon":66.447365, "validposition":1, "altitude":39000,  "vert_rate":-64,"track":125, "validtrack":1,"speed":482, "messages":201, "seen":219}

The query I'm running and works is the following:

select * from flight_series where time > now() - 30m and flight !~ /^$/ and validtrack = 1 and validposition = 1;

Trough it I'm trying to take the last 30 minutes from the current time, check that the flight field is no whitespaces and that the track/position are valid. The query returns successfully but when I'm adding the

into filtered_log

part the 'where' clause is ignored.

How can I create a continuous query which takes the above-mentioned conditions into consideration? At least, how could I extract with one continuous query only the rows which have the valid track/heading set to 1 and the flight is not whitespace/empty string? The time constraint I could eliminate from the query and translate into shard retention/duration.

Also, could I specify to in the continuous query to save the data into a time-series which is located into another database (which has a more relaxed retention/duration policy)?

Thank you!

Later edit:

I've managed to do something closer to my need by using the following cq:

"select time, sequence_number, altitude, vert_rate, messages, squawk, lon, lat, speed, hex, seen from current_flights where ((flight !~ /^$/) AND (validtrack = 1)) AND (validposition = 1) into flight.[flight]"

This creates a series for each 'flight' even for those which have a whitespace in the 'flight' field -- for which a flight. series is built.

How could I specify the retention/duration policies for the series generated by the cq above? Can I do something like:

"spaces": [
    {
      "name": "flight",
      "retentionPolicy": "1h",
      "shardDuration": "30m",
      "regex": "/.*/",
      "replicationFactor": 1,
      "split": 1
    },
 ...

which would give me a retention of 1h and shard duration of 30m?

I'm a bit confused about where those series are stored, which shard space?

Thanks!

P.S.: My final goal would be the following: Have a 'window' of 15-30min max with all the flights around, process some data from them and after that period is over discard the data but in the same time move/copy it to another long-term db/series which can be used for historical purposes.

解决方案

You cannot put time restrictions into the WHERE clause of a continuous query. The server will generate the time restrictions as needed when the CQ runs and must ignore all others. I suspect if you leave out the time restriction the rest of the WHERE clause will be fine.

I don't believe CQs in 0.8 require an aggregation in the SELECT, but you do need to have GROUP BY clause to tell the CQ how often to run. I'm not sure what you would GROUP BY, perhaps the flight?

You can specify a different retention policy when writing to the new series but not a new database. In 0.8 the retention policy for a series is determined by regex matching on the series name. As long as you select a series name correctly it will go into your desired retention policy.

EDIT: updates for new questions

How could I specify the retention/duration policies for the series generated by the cq above?

In 0.8.x, the shard space to which a series belongs controls the retention policy. The regex on the shard space determines which series belong to that shard. The shard space regex is evaluated newest to oldest, meaning the first created shard space will be the last regex evaluated. Unfortunately, I do know if it is possible to create new shard spaces once the database exists. See this discussion on the mailing list for more: https://groups.google.com/d/msgid/influxdb/ce3fc641-fbf2-4b39-9ce7-77e65c67ea24%40googlegroups.com

Can I do something like:

"spaces": [ { "name": "flight", "retentionPolicy": "1h", "shardDuration": "30m", "regex": "/.*/", "replicationFactor": 1, "split": 1 }, ... which would give me a retention of 1h and shard duration of 30m?

That shard space would have a shard duration of 30 minutes, retaining data for 1 hour, meaning any series would only exist in three shards, the current hot shard, the current cold shard, and the shard waiting for deletion.

The regex is /./, meaning it would match any series, not just the 'flight.' series. Perhaps /flight../ is a better regex if you only want those series generated by the CQ in that shard space.

这篇关于Influxdb中连续查询忽略where子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆