InfluxDB Quick Start
来自Jack's Lab
(版本间的差异)
(→Overview) |
(→Database) |
||
第5行: | 第5行: | ||
A logical container for users, retention policies, continuous queries, and time series data | A logical container for users, retention policies, continuous queries, and time series data | ||
− | <br><br> | + | <br> |
+ | |||
+ | === Measurement === | ||
+ | |||
+ | The part of InfluxDB’s structure that describes the data stored in the associated fields. Measurements are strings. | ||
+ | |||
+ | <br> | ||
== influx shell == | == influx shell == |
2017年5月11日 (四) 18:40的版本
目录 |
1 Overview
1.1 Database
A logical container for users, retention policies, continuous queries, and time series data
1.2 Measurement
The part of InfluxDB’s structure that describes the data stored in the associated fields. Measurements are strings.
2 influx shell
$ influx Connected to http://localhost:8086 version 1.2.x InfluxDB shell 1.2.x > show databases; name: databases name ---- _internal test telegraf > use telegraf; Using database telegraf > show measurements; name: measurements name ---- cpu disk diskio kernel mem processes swap system >
3 Creating a database
$ curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb" $ influx Connected to http://localhost:8086 version 1.2.x InfluxDB shell 1.2.x > create database mydb; > show databases; name: databases name ---- _internal test telegraf mydb
4 Insert data
> USE mydb > INSERT cpu,host=serverA,region=us_west value=0.64 > select * from cpu; name: cpu time host region value ---- ---- ------ ----- 1494498034415516860 serverA us_west 0.64
Syntax:
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]
5 Writing data
$ curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load,host=server01,region=us-west value=0.64'
6 Queries
$ curl -GET 'http://raspberrypi:8086/query?pretty=true' \ --data-urlencode "db=mydb" --data-urlencode \ "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'" \ | jq '.results[0].series'
7 Advanced Queries
> SELECT COUNT("water_level") FROM "h2o_feet" \ WHERE time >= '2015-08-19T00:00:00Z' \ AND time <= '2015-08-27T17:00:00Z' \ AND "location"='coyote_creek' GROUP BY time(3d)