LoginSignup
3
2

More than 1 year has passed since last update.

InfluxDB v1.8: cli の使い方

Last updated at Posted at 2018-11-13

InfluxDB v1.8 の cli の使い方です。

サーバーのインストール方法

Ubuntu 22.10

wget https://dl.influxdata.com/influxdb/releases/influxdb_1.8.10_amd64.deb
sudo dpkg -i influxdb_1.8.10_amd64.deb

バージョンの確認

$ influx -version
InfluxDB shell version: 1.8.10

サーバーの起動

sudo systemctl start influxdb

cli の サンプル

$ influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
Enter an InfluxQL query
> create database city
> use city
Using database city
> insert tochigi,key=t0921 name="宇都宮",population=34981,date_mod="2003-8-12"
> insert tochigi,key=t0922 name="小山",population=51982,date_mod="2003-7-20"
> insert tochigi,key=t0923 name="佐野",population=75984,date_mod="2003-9-8"
> select * from tochigi
name: tochigi
time                date_mod  key   name population
----                --------  ---   ---- ----------
1542096873488107961 2003-8-12 t0921 宇都宮  34981
1542096879379152598 2003-7-20 t0922 小山   51982
1542096884529336419 2003-9-8  t0923 佐野   75984
> quit

time の表示を見やすくするには、
ただし、時刻は UTF です。

$ influx -precision rfc3339
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> use city
Using database city
> select * from tochigi
name: tochigi
time                           date_mod  key   name population
----                           --------  ---   ---- ----------
2022-12-05T08:12:58.718002103Z 2003-7-20 t0922 小山   51982
2022-12-05T08:13:08.290512976Z 2003-8-12 t0921 宇都宮  34981
2022-12-05T08:13:26.921954067Z 2003-9-8  t0923 佐野   75984
> 

よく使うコマンド

show databases
use city
show measurements

API を使ってデータの確認

GET でアクセス

curl -G 'http://localhost:8086/query?db=city' --data-urlencode 'q=SELECT * FROM "tochigi"' | jq . | less
http 'http://localhost:8086/query?db=city&q=SELECT * FROM "tochigi"'

POST でアクセス

curl -XPOST 'http://localhost:8086/query?db=city' --data-urlencode 'q=SELECT * FROM "tochigi"'  | jq . | less
http --form POST http://localhost:8086/query db=city q='SELECT * FROM "tochigi"'

参考ページ

Influx Query Language (InfluxQL) reference

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2