InfluxDB where 查询标签值

发布于 2025-01-09 07:24:43 字数 539 浏览 6 评论 0原文

我正在尝试在 InfluxDB 上编写一个 where 子句,其中的点通过其键值进行过滤。

我的点包含字段 ping_to_google.com 和标签键 user,其中用户可以是 raspi-2raspi-5.这是数据库的示例输出:

> select * from networks where time > now()-1h
name: networks
time                 ping_to_google.com user
----                 ------------------ ----
1645494054000000000  3.528              raspi-2
1645494078000000000  3.578              raspi-2

我正在使用 InfluxDB 版本 1.8 和 InfluxDB shell 版本 1.6.4

I am trying to write a where clause on InfluxDB where the points are filtered via their key values.

My points have the field ping_to_google.com and the tag key user where user can be raspi-2 or raspi-5. This is a sample output of the database:

> select * from networks where time > now()-1h
name: networks
time                 ping_to_google.com user
----                 ------------------ ----
1645494054000000000  3.528              raspi-2
1645494078000000000  3.578              raspi-2

I am using InfluxDB version 1.8 and InfluxDB shell version 1.6.4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2025-01-16 07:24:43

这个查询会起作用!

select * from networks where time > now()-1h AND "user"='raspi-2'

根据 influxDB 的文档,您应该仅单个 qoute 标记值:

Tags

tag_key; ['tag_value']

WHERE 子句中的单引号标记值。使用不带引号的标记值或双引号标记值的查询将不会返回任何数据,并且在大多数情况下不会返回错误。

他们没有指定如何编写标签键。令人疯狂的是,数据库在大多数情况下不会产生任何错误。另外,尚不清楚(在阅读本文档后非常意外)标签键应该是双引号的。但这是有效的,并且是如何做到的!

This query will work!

select * from networks where time > now()-1h AND "user"='raspi-2'

According to the documentation of the influxDB you should only single qoute tag values:

Tags

tag_key <operator> ['tag_value']

Single quote tag values in the WHERE clause. Queries with unquoted tag values or double quoted tag values will not return any data and, in most cases, will not return an error.

They don't specify how to write tag keys. It is crazy that the database does not produce any errors in most cases. Also, it's not clear (and very unexpected after reading this documentation) that the tag key should be double-qouted. But this works and is how to do it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文