查看InfluxDB Quick Start的源代码
←
InfluxDB Quick Start
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Key Concepts == === Database === A logical container for users, retention policies, continuous queries, and time series data <br> === Measurement === The part of InfluxDB’s structure that describes the data stored in the associated fields. Measurements are strings. <br> === Tag === The key-value pair in InfluxDB’s data structure that records metadata. Tags are an optional part of InfluxDB’s data structure but they are useful for storing commonly-queried metadata; tags are indexed so queries on tags are performant. Query tip: Compare tags to fields; fields are not indexed. <br> ==== Tag Key ==== The key part of the key-value pair that makes up a tag. Tag keys are strings and they store metadata. Tag keys are indexed so queries on tag keys are performant. Query tip: Compare tag keys to field keys; field keys are not indexed. <br> ==== Tag Value ==== The value part of the key-value pair that makes up a tag. Tag values are strings and they store metadata. Tag values are indexed so queries on tag values are performant. <br> ==== Tag Set ==== The collection of tag keys and tag values on a point. <br> === Field === The key-value pair in InfluxDB’s data structure that records metadata and the actual data value. Fields are required in InfluxDB’s data structure and they are <b>not indexed</b> - queries on field values scan all points that match the specified time range and, as a result, are not performant relative to tags. Query tip: Compare fields to tags; <b>tags are indexed.</b> <br> ==== Field Key ==== The key part of the key-value pair that makes up a field. Field keys are strings and they store metadata. <br> ==== Field Value ==== The value part of the key-value pair that makes up a field. * Field values are the actual data; * They can be strings, floats, integers, or booleans. * It is always associated with a timestamp. <b>Field values are not indexed</b> - queries on field values scan all points that match the specified time range and, as a result, are not performant. Query tip: Compare field values to tag values; tag values are indexed. <br> ==== Field Set ==== The collection of field keys and field values on a point. <br> === Series === The collection of data in InfluxDB’s data structure that share a measurement, tag set, and retention policy. Note: The field set is not part of the series identification! <br><br> == Influx shell == <source lang=bash> $ 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 > </source> <br><br> == Create a database == <source lang=bash> $ 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 </source> Or: $ curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb" <br><br> == Drop a database == <source lang=bash> > show databases; name: databases name ---- _internal test telegraf mydb > drop database test; > show databases; name: databases name ---- _internal telegraf mydb > </source> <br><br> == Insert data == <source lang=bash> > 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 </source> <b>Syntax:</b> <measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp] <source lang=bash> $ curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load,host=server01,region=us-west value=0.64' </source> <br><br> == Queries == === Show === <source lang=bash> > use mydb Using database mydb > show series key --- cpu,host=serverA,region=us_west cpu_load_short,host=server01,region=us-west > show tag keys name: cpu tagKey ------ host region name: cpu_load_short tagKey ------ host region > show tag keys from cpu name: cpu tagKey ------ host region > show field keys name: cpu fieldKey fieldType -------- --------- value float name: cpu_load_short fieldKey fieldType -------- --------- value float > show field keys from cpu name: cpu fieldKey fieldType -------- --------- value float </source> A real example: <source lang=bash> > use telegraf Using database telegraf > show series key --- cpu,cpu=cpu-total,host=jackslab cpu,cpu=cpu0,host=jackslab cpu,cpu=cpu1,host=jackslab disk,device=rootfs,fstype=rootfs,host=jackslab,path=/ disk,device=sdb1,fstype=ext4,host=jackslab,path=/ disk,device=sdb2,fstype=ext4,host=jackslab,path=/work disk,device=sdb4,fstype=vfat,host=jackslab,path=/data diskio,host=jackslab,name=sda diskio,host=jackslab,name=sda1 diskio,host=jackslab,name=sda2 diskio,host=jackslab,name=sda5 diskio,host=jackslab,name=sdb diskio,host=jackslab,name=sdb1 diskio,host=jackslab,name=sdb2 diskio,host=jackslab,name=sdb3 diskio,host=jackslab,name=sdb4 kernel,host=jackslab mem,host=jackslab net,host=jackslab,interface=all net,host=jackslab,interface=wlan0 netstat,host=jackslab nstat,host=jackslab,name=netstat nstat,host=jackslab,name=snmp nstat,host=jackslab,name=snmp6 processes,host=jackslab swap,host=jackslab system,host=jackslab > show measurements name: measurements name ---- cpu disk diskio kernel mem net netstat nstat processes swap system > show field keys from mem name: mem fieldKey fieldType -------- --------- active integer available integer available_percent float buffered integer cached integer free integer inactive integer total integer used integer used_percent float > show tag keys from mem name: mem tagKey ------ host </source> <source lang=bash> $ 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' </source> <br><br> == Advanced Queries == <source lang=bash> > 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) </source> <source lang=bash> > select * from system limit 1; name: system time host load1 load15 load5 n_cpus n_users uptime uptime_format ---- ---- ----- ------ ----- ------ ------- ------ ------------- 1494233380000000000 jackslab 0.09 0.28 0.29 2 6 807623 9 days, 8:20 > show tag keys from system; name: system tagKey ------ host > show field keys from system; name: system fieldKey fieldType -------- --------- load1 float load15 float load5 float n_cpus integer n_users integer uptime integer uptime_format string > select * from system order by time desc limit 5; name: system time host load1 load15 load5 n_cpus n_users uptime uptime_format ---- ---- ----- ------ ----- ------ ------- ------ ------------- 1495615580000000000 jackslab 0.4 0.23 0.21 2 4 1028371 11 days, 21:39 1495615570000000000 jackslab 0.02 0.2 0.13 2 4 1028361 11 days, 21:39 1495615560000000000 jackslab 0.02 0.2 0.13 2 4 1028351 11 days, 21:39 1495615550000000000 jackslab 0.03 0.21 0.14 2 4 1028341 11 days, 21:39 1495615540000000000 jackslab 0.03 0.21 0.14 2 4 1028331 11 days, 21:38 </source> Only 'order by time' can work. 'order by uptime' can not work * https://docs.influxdata.com/influxdb/v1.0/query_language/data_exploration/ <br><br> == Backup == <source lang=bash> $ influxd backup /tmp/backup 2017/08/31 09:52:26 backing up metastore to /tmp/backup/meta.00 2017/08/31 09:52:26 backup complete $ ls /tmp/backup/ -lht -rw-r--r-- 1 comcat inetsim 1.9K 8月 31 09:52 meta.00 $ influxd backup -database elecdb /tmp/backup/ 2017/08/31 09:53:38 backing up db=elecdb since 0001-01-01 00:00:00 +0000 UTC 2017/08/31 09:53:38 backing up metastore to /tmp/backup/meta.01 2017/08/31 09:53:38 backing up db=elecdb rp=autogen shard=117 to /tmp/backup/elecdb.autogen.00117.00 since 0001-01-01 00:00:00 +0000 UTC 2017/08/31 09:53:39 backing up db=elecdb rp=autogen shard=123 to /tmp/backup/elecdb.autogen.00123.00 since 0001-01-01 00:00:00 +0000 UTC 2017/08/31 09:53:39 backing up db=elecdb rp=autogen shard=130 to /tmp/backup/elecdb.autogen.00130.00 since 0001-01-01 00:00:00 +0000 UTC 2017/08/31 09:53:39 backup complete $ ls -lht /tmp/backup/ -rw-r--r-- 1 comcat inetsim 9.6M 8月 31 09:53 elecdb.autogen.00130.00 -rw-r--r-- 1 comcat inetsim 2.1M 8月 31 09:53 elecdb.autogen.00123.00 -rw-r--r-- 1 comcat inetsim 1.0K 8月 31 09:53 elecdb.autogen.00117.00 -rw-r--r-- 1 comcat inetsim 1.9K 8月 31 09:53 meta.01 -rw-r--r-- 1 comcat inetsim 1.9K 8月 31 09:52 meta.00 $ sudo du -sh /var/lib/influxdb/ 205M /var/lib/influxdb/ $ sudo du -sh /var/lib/influxdb/data/* 12M /var/lib/influxdb/data/elecdb 5.7M /var/lib/influxdb/data/_internal 24K /var/lib/influxdb/data/mydb 166M /var/lib/influxdb/data/telegraf </source> Take a backup of the autogen retention policy for the telegraf database since midnight UTC on Augest 1st, 2017 by using the command: <source lang=bash> $ influxd backup -database telegraf -retention autogen -since 2017-08-01T00:00:00Z /tmp/backup </source> ;;Remote backup: <source lang=bash> $ influxd backup -database mydb -host <remote-node-IP>:8088 /tmp/snapshot </source> <br><br> == Restore == <source lang=bash> </source> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br> <br><br>
返回到
InfluxDB Quick Start
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面