Influxdb客户端使用
Influxdb客户端使用
1. 简介
Influxdb在网络上可以搜索到一个叫InfluxdbStudio的工具,但只能在window下使用,有时在其他系统下做简单数据查询时就比较麻烦,下面以Influxdb V1.8.0版本为例介绍一下其他的方法。
2. 使用influxdb-client工具
influxdb-client是官方的客户端命令行工具,使用起来也比较舒服,现在使用的版本是InfluxDB shell version: 1.8.6
influx -host 1.0.0.5 -port 8086 -username admin -password admin -precision rfc3339
Connected to http://1.0.0.5:8086 version 1.8.0
InfluxDB shell version: 1.8.6
> help
Usage:
connect <host:port> connects to another node specified by host:port
auth prompts for username and password
pretty toggles pretty print for the json format
chunked turns on chunked responses from server
chunk size <size> sets the size of the chunked responses. Set to 0 to reset to the default chunked size
use <db_name> sets current database
format <format> specifies the format of the server responses: json, csv, or column
precision <format> specifies the format of the timestamp: rfc3339, h, m, s, ms, u or ns
consistency <level> sets write consistency level: any, one, quorum, or all
history displays command history
settings outputs the current settings for the shell
clear clears settings such as database or retention policy. run 'clear' for help
exit/quit/ctrl+d quits the influx shell
show databases show database names
show series show series information
show measurements show measurement information
show tag keys show tag key information
show field keys show field key information
A full list of influxql commands can be found at:
https://docs.influxdata.com/influxdb/latest/query_language/spec/
> use ssdata;
Using database ssdata
> select x,y,z from data02 limit 10;
name: data02
time x y z
---- - - -
2022-09-15T02:02:53Z 123.4562365413 41.7171729195 56.104
2022-09-15T02:02:53.005Z 123.4562365513 41.7171728794 56.102
2022-09-15T02:02:53.01Z 123.4562365313 41.7171729595 56.106
2022-09-15T02:02:53.015Z 123.4562365114 41.7171730295 56.111
2022-09-15T02:02:53.02Z 123.4562365014 41.7171731096 56.116
2022-09-15T02:02:53.025Z 123.4562364815 41.7171731896 56.12
2022-09-15T02:02:53.03Z 123.4562364615 41.7171732697 56.125
2022-09-15T02:02:53.035Z 123.4562364516 41.7171733497 56.129
2022-09-15T02:02:53.04Z 123.4562364316 41.7171734298 56.134
2022-09-15T02:02:53.045Z 123.4562364117 41.7171735098 56.138
`默认是rfc3339的时间格式,修改格式 `
> precision ms
> select x,y,z from data02 limit 10;
name: data02
time x y z
---- - - -
1663207373000 123.4562365413 41.7171729195 56.104
1663207373005 123.4562365513 41.7171728794 56.102
1663207373010 123.4562365313 41.7171729595 56.106
1663207373015 123.4562365114 41.7171730295 56.111
1663207373020 123.4562365014 41.7171731096 56.116
1663207373025 123.4562364815 41.7171731896 56.12
1663207373030 123.4562364615 41.7171732697 56.125
1663207373035 123.4562364516 41.7171733497 56.129
1663207373040 123.4562364316 41.7171734298 56.134
1663207373045 123.4562364117 41.7171735098 56.138
3. 使用浏览器工具
在浏览器内直接输入:
http://1.0.0.5:8086/query?db=ssdata&u=admin&p=admin&epoch=ms&q=select * from data_cpt02 limit 10
支持的查询参数有:https://docs.influxdata.com/influxdb/v2.4/reference/api/influxdb-1x/query/
Query string parameters
u
(Optional) The 1.x username to authenticate the request. See query string authentication.
p
(Optional) The 1.x password to authenticate the request. See query string authentication.
db
(Required) The database to query data from. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.
rp
The retention policy to query data from. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.
q
(Required) The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (;).
epoch
Return results with Unix timestamps (also known as epoch timestamps) in the specified precision instead of RFC3339 timestamps with nanosecond precision. The following precisions are available:
ns - nanoseconds
u or µ - microseconds
ms - milliseconds
s - seconds
m - minutes
h - hours
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY