InfluxDB is the Time Series Database in the TICK Stack
InfluxData’s TICK Stack is built around InfluxDB to handle massive amounts of time-stamped information. This time series database provides support for your metrics analysis needs, from DevOps Monitoring, IoT Sensor data, and Real-Time Analytics. Users can adapt their SQL skills with InfluxQL, so they can get up to speed on this time series database.
# 查询所有数据 SELECT * FROM "cpu" SELECT "host","load","usage" FROM "cpu"
# 根据条件查询 SELECT "host","load","usage" FROM "cpu" WHERE "host" = '192.168.1.1' SELECT "host","load","usage" FROM "cpu" WHERE "usage" > 0.1
# 创建数据库 CREATE DATABASE "db_name" # 显示所有数据库 SHOW DATABASES # 删除数据库 DROP DATABASE "db_name"
# 使用数据库 USE mydb # 显示该数据库中的表 SHOW MEASUREMENTS # 删除表 DROP MEASUREMENT "t_name"
# 简单查询 SELECT * FROM codis_usage ORDER BY time DESC LIMIT 3 # 最近60min内的数据 SELECT * FROM codis_usage WHERE time >= now() - 60m; # 获取最近更新数据,并转换为当前时间 precision rfc3339 select * from codis_usage order by time desc limit 10;
# 查询保存策略 show retention policies on codis name duration shardGroupDuration replicaN default ---- -------- ------------------ -------- ------- autogen 0s 168h0m0s 1 true
[root@sg-gop-10-71-12-145 wangao]# influx Connected to http://localhost:8086 version 1.7.7 InfluxDB shell version: 1.7.7 > 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/ >
# 获取最近更新数据,并转换为当前时间 select threads_running from mysql order by time desc limit 1; date -d @`echo 1483441750000000000 | awk '{print substr($0,1,10)}'` +"%Y-%m-%d %H:%M:%S"
# 检查系统是否存活 $ curl -sl -I localhost:8086/ping
# 简单查询 SELECT * FROM weather ORDER BY time DESC LIMIT 3;
# 指定时间范围,时间格式也可以为'2017-01-03 00:00:00' SELECT usage_idle FROM cpu WHERE time >= '2017-01-03T12:40:38.708Z' AND time <= '2017-01-03T12:40:50.708Z';
# 最近40min内的数据 SELECT * FROM mysql WHERE time >= now() - 40m;
# 最近5分钟的秒级差值 SELECT derivative("queries", 1s) AS "queries" from "mysql" where time > now() - 5m;
# 最近5min的秒级写入 $ influx -database '_internal' -precision 'rfc3339' -execute 'select derivative(pointReq, 1s) from "write" where time > now() - 5m'