开源时序服务器influxdb使用
文档
https://influxdb.com/docs/v0.9/introduction/overview.html
配置文件
/etc/opt/influxdb/influxdb.conf
reporting-disabled = false
[meta]
dir = "/var/opt/influxdb/meta"
hostname = "localhost"
bind-address = ":8088"
retention-autocreate = true
election-timeout = "1s"
heartbeat-timeout = "1s"
leader-lease-timeout = "500ms"
commit-timeout = "50ms"
[data]
dir = "/var/opt/influxdb/data"
MaxWALSize = 104857600 # Maximum size the WAL can reach before a flush. Defaults to 100MB.
WALFlushInterval = "10m" # Maximum time data can sit in WAL before a flush.
WALPartitionFlushDelay = "2s" # The delay time between each WAL partition being flushed.
[cluster]
shard-writer-timeout = "5s"
[retention]
enabled = true
check-interval = "10m"
[admin]
enabled = true
bind-address = ":8083"
[http]
enabled = true
bind-address = ":8086"
auth-enabled = false
log-enabled = true
write-tracing = false
pprof-enabled = false
[[graphite]]
enabled = false
# bind-address = ":2003"
# protocol = "tcp"
# consistency-level = "one"
# name-separator = "."
## e.g. "type.host.measurement.device" will parse "server.localhost.cpu.cpu0" as
## {
## measurement: "cpu",
## tags: {
## "type": "server",
## "host": "localhost,
## "device": "cpu0"
## }
## }
# name-schema = "type.host.measurement.device"
# ignore-unnamed = true
[collectd]
enabled = false
# bind-address = ""
# database = ""
# typesdb = ""
[opentsdb]
enabled = false
# bind-address = ""
# database = ""
# retention-policy = ""
[udp]
enabled = false
# bind-address = ""
# database = ""
# batch-size = 0
# batch-timeout = "0"
[monitoring]
enabled = true
write-interval = "24h"
[continuous_queries]
enabled = true
recompute-previous-n = 2
recompute-no-older-than = "10m"
compute-runs-per-interval = 10
compute-no-more-than = "2m"
[hinted-handoff]
enabled = true
dir = "/var/opt/influxdb/hh"
max-size = 1073741824
max-age = "168h"
retry-rate-limit = 0
retry-interval = "
协议
- influxdb的数据由时间序列(time series)组织,包含度量值(measurement),像cpu_load, temperature等等。2
- 时间序列有0个或多个记录点(points),每个指标一个离散样本。
- points包含timestamp和measurement,至少一个key-value域(fields),例如 value=0.64 or 15min=0.78,0或多个key-value标签(tags),包含元数据(metadata),例如host=server01,region=EMEA,dc=Frankfurt。
- 从概念上讲,可以把measurement想象是一个sql表,row行是主索引,tags和fields是表中的列,tag是索引,fileds不是。
points example
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]
cpu,host=serverA,region=us_west value=0.64 payment,device=mobile,product=Notepad,method=credit billed=33,licenses=3 1434067467100293230 stock,symbol=AAPL bid=127.46,ask=127.48 temperature,machine=unit42,type=assembly external=25,internal=37 1434067467000000000
接口
CLI
# 建立数据库
create database <name>
# 使用数据库
use <name>
# 显示所有存在数据库
show databases;
name: databases
---------------
name
collectd
test
# 建立保留策略(retention policy)
create retention policy rp_collectd on collectd duration 1w replication 1 default
duration: 1h, 90m, 12h, 7d, 4w, INF 最小1h, 最大INF
# 显示保留策略
show retention policies on dashboard
name duration replicaN default
default 0 1 false
rp_dashboard 168h0m0s 1 true
# 修改保留策略
alter retention policy rp_collectd on collectd duration 2d
# 当前数据库插入数据,measure是cpu, tag是host..., 值是0.64
insert cpu,host=serverA,region=us_west value=0.64
# measure查询cpu
select * from cpu
name: cpu
tags: host=serverA, region=us_west
time value
---- -----
2015-07-20T04:27:25.960705835Z 0.64
# 插入2个值的measure temperature
insert temperature,machine=unit42,type=assembly external=25,internal=37
# measure查询temperature
select * from temperature
name: temperature
tags: machine=unit42, type=assembly
time external internal
---- -------- --------
2015-07-20T04:29:17.253782361Z 25 37
(max values 255)
# select * from /.*/ LIMIT 1
# select * from cpu_load_short
# select * from cpu_load_short WHERE value > 0.9
# 显示所有measurements
show measurements;
name: measurements
------------------
name
cpu
temperature
# 显示所有时间序列
show series
name: cpu
---------
_key host region
cpu,host=serverA,region=us_west serverA us_west
name: temperature
-----------------
_key machine type
temperature,machine=unit42,type=assembly unit42 assembly
HTTP
POST to the endpoint /write
# 建立数据库
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
# 写数据
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
timestamp可选,如果没有,使用服务器当前时间。
retention policy query parameter (rp),数据保留时间,默认是系统配置文件中的。
# 写多条数据
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 cpu_load_short,host=server02,region=us-west value=0.55 1422568543702900257 cpu_load_short,direction=in,host=server01,region=us-west value=23422.0 1422568543702900257'
# 时间格式
curl -i -XPOST 'http://localhost:8086/write?db=mydb&precision=s' --data-binary 'temperature,machine=unit42,type=assembly external=25,internal=37 1434059627'
precision=s 不指定,系统默认使用ns,可用的n, u, ms, s, m, h
GET to the endpoint /query
# 读数据
curl -G 'http://localhost:8086/query' --data-urlencode "db=mydb" --data-urlencode "epoch=s" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"
epoch= 时间格式,不指定,系统默认使用ns,n, u, ms, s, m, h
q=请求命令
返回格式
{
"results": [
{
"series": [{}],
"error": "...."
}
],
"error": "...."
}
# 读多条数据
curl -G 'http://localhost:8086/query' --data-urlencode "db=mydb" --data-urlencode "q=SELECT * FROM cpu_load_short WHERE region=us-west;SELECT * FROM temperature"
用分号间隔
# GET请求需要认证
/query?u=bob&p=mypass
Pretty Printing
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT * FROM cpu_load_short"
数据库是唯一存在的,是包含users、retention policies、continuous queries的容器。
Retention Policy是建库时默认指定的,确定数据的保存时间。
Duration是Retention Policy不存在时,确定数据的保存时间,不能小于1小时,单位minutes, hours, days, or weeks, with INF(infinite无限)。
Aggregations
COUNT, MEAN, SUM, MEDIAN, PERCENTILE, MIN, MAX, SPREAD, STDDEV, DERIVATIVE, NON_NEGATIVE_DERIVATIVE, DISTINCT, FIRST, and LAST.
show measurements
show measurements with host='server1'
show tag keys
show tag keys from cpu
show tag values from cpu with key='region'
show series
show series with serice='redis'
select * from some_series where time > now() - 1h
# aggregates
select percentile(90, value) from cpu where time > now() - 1d group by time(10m), region
# regex
select value from some_series where value =~ /.*ERROR.*/ and time > '2014-03-01' and time < '2014-4-1'
select value from some_series where host =~ /.*asdf.*/ and time > '2014-03-01' and time < '2014-4-1' group by host
开源时序服务器influxdb使用的更多相关文章
- 时序数据库InfluxDB安装及使用
时序数据库InfluxDB安装及使用 1 安装配置 安装 wget https://dl.influxdata.com/influxdb/releases/influxdb-1.3.1.x86_64. ...
- 时序数据库InfluxDB
在系统服务部署过后,线上运行服务的稳定性是系统好坏的重要体现,监控系统状态至关重要,经过调研了解,时序数据库influxDB在此方面表现优异. influxDB介绍 时间序列数据是以时间字段为每行数据 ...
- 时序数据库InfluxDB(I)- 搭建与采集信息demo操作
搭建环境:vmware workstation pro15.5.0, ubuntu18.04.3 实践时间:2019.10.12-10.27 (一)时序数据库InfluxDB准备 (1)安装 曾出现问 ...
- Spring Boot中使用时序数据库InfluxDB
除了最常用的关系数据库和缓存之外,之前我们已经介绍了在Spring Boot中如何配置和使用MongoDB.LDAP这些存储的案例.接下来,我们继续介绍另一种特殊的数据库:时序数据库InfluxDB在 ...
- 简析时序数据库 InfluxDB
时序数据基础 时序数据特点 时序数据TimeSeries是一连串随时间推移而发生变化的相关事件. 以下图的 CPU 监控数据为例,同个 IP 的相关监控数据组成了一条时序数据,不相关数据则分布在不同的 ...
- 部署rfc5766-turn-server--谷歌推荐的开源穿透服务器 [复制链接]
谷歌推荐的开源穿透服务器,包含trun和stun服务,主页:https://code.google.com/p/rfc5766-turn-server/(个人觉得可以利用这个来进一步搭建VPN,有兴趣 ...
- 搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用
搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用 分类: linux编译相关2013-01-05 21:38 17983人阅读 评论(24) 收藏 举报 先下载 ...
- Windows下免费、开源邮件服务器hMailServer
Windows下免费.开源邮件服务器hMailServer 一.Windows下搭建免费.开源的邮件服务器hMailServer 二.邮件服务器hMailServer管理工具hMailServer A ...
- 开源流媒体服务器SRS学习笔记(1) - 安装、推流、拉流
SRS(Simple RTMP Server) 是国人写的一款非常优秀的开源流媒体服务器软件,可用于直播/录播/视频客服等多种场景,其定位是运营级的互联网直播服务器集群. 一.安装 官网提供了3种安 ...
随机推荐
- ssh证书生成与配置
cd /usr/local/nginx/conf openssl genrsa -des3 - //key文件为私钥 openssl rsa -in tmp.key -out aminglinux.k ...
- kindedtor的基本使用
首先需要进入官网下载kineditor相关文件: 然后写代码: <!DOCTYPE html> <html> <head> <meta charset=&qu ...
- innodb的读写参数优化
(1) 读取参数,global buffer pool以及 local buffer Innodb_buffer_pool_size,理论上越大越好,建议服务器50%~80%,实际为数据大小80 ...
- 设置IIS,使客户端访问服务器上的文件
1.打开IIS控制器——"运行-cmd-inetmgr-回车“ 2.选中要设置的网站 3.右键,添加虚拟目录 4.如上图所示,在别名处输入文件目录的名称,物理路径要选择文件在磁盘上的存储根目 ...
- HDU - 1878 欧拉回路 (连通图+度的判断)
欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路.现给定一个图,问是否存在欧拉回路? Input 测试输入包含若干测试用例.每个测试用例的第1行给出两个正整数,分别是节点数 ...
- java mybatis学习一
1.引入maven包 和 导入 sqljdbc包 <dependency> <groupId>org.apache.ibatis</groupId> <art ...
- msyql操作100题
1.1.1 开启MySQL服务 /etc/init.d/mysqld start 使用/etc/init.d/mysqld start命令启动数据库的本质就相当于执行mysqld_safe --use ...
- 树莓派安装摄像头 C110 motion
### 1.修改成国内的软件源,否则会失败或下载太慢sudo vi /etc/apt/sources.listdeb http://mirrors.aliyun.com/raspbian/raspbi ...
- Netcore中实现字段和属性注入
https://www.cnblogs.com/loogn/p/10566510.html 简单来说,使用Ioc模式需要两个步骤,第一是把服务注册到容器中,第二是从容器中获取服务,我们一个一个讨论并演 ...
- 20-----BBS论坛
BBS论坛(二十) 20.1.cms添加轮播图后台逻辑代码完成 (1)apps/models.py from exts import db from datetime import datetime ...