Query Influxdb based on tags?

时间:2016-07-11 22:59:30

标签: influxdb

I have started playing around with Influxdb v0.13 and I have some dummy values in my test db where id is a tag and value is a field:

> SELECT * FROM dummy
name: dummy
--------------
time                    id     value
1468276508161069051     1234    12345
1468276539152853428     613     352
1468276543470535110     613     4899
1468276553853436191     1234    12

I get no results returned when I run this query:

> SELECT * FROM dummy WHERE id=1234

but I do get the following when querying with the field instead:

> SELECT * FROM dummy WHERE value=12
name: dummy
--------------
time                    id     value
1468276553853436191     1234    12

Am I doing something wrong here? I thought the point of tags were to be queried (since they are indexed and fields are not), but they seem to break my queries.

1 个答案:

答案 0 :(得分:8)

看来Influx会将每个标记键和我们插入的值视为字符串,这显然在他们的官方文档中显示。

请参阅:https://docs.influxdata.com/influxdb/v0.13/guides/writing_data/

  

写入点时,必须在db中指定现有数据库   查询参数。请参阅“写入语法”页面上的HTTP部分   完整的可用查询参数列表。 POST的正文    - 我们称之为线路协议 - 包含您希望存储的时间序列数据。它们包括测量,标签,字段和a   时间戳。 InfluxDB需要一个测量名称。 严格来说,   标签是可选的,但大多数系列都包含用于区分数据的标签   来源和使查询既简单又有效。两个标签键   和标签值是字符串。

注意:文字用粗体表示。

因此,要按标记键值过滤 - 必须引用查询。

示例

SELECT * FROM dummy WHERE id='1234'