开源时序服务器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种安 ...
随机推荐
- 勤哲excel服务器WEB网页环境搭建问题解决
因为客户希望在浏览器上使用勤哲的功能,因此希望大家勤哲excel服务器的web环境. 他们用的是勤哲2010版,需要装到64位环境下.在搭建的时候,遇到2个主要问题. 问题1:编译器错误消息: BC3 ...
- Spring注解实现定时功能以及Quartz定时器
一:Spring注解实现--------->Spring3.0以后自带的task,可以将它看成一个轻量级的Quartz 1:maven配置: <!-- quartz--> <d ...
- FPGA实战操作(1) -- SDRAM(Verilog实现)
对SDRAM基本概念的介绍以及芯片手册说明,请参考上一篇文章SDRAM操作说明. 1. 说明 如图所示为状态机的简化图示,过程大概可以描述为:SDRAM(IS42S16320D)上电初始化完成后,进入 ...
- Django 解答 01 (pycharm创建项目)
pycharm创建项目 1. 2. 3.Tools --->Deployment--->Options 这一条由always 改为 On explicit save action(Ctrl ...
- Kibana 视图开发入门参考文档
官方教程:https://www.elastic.co/blog/developing-new-kibana-visualizations GitHub源码:https://github.com/el ...
- 网络流之最大流与最小费用流入门&&模板
理解处 刷题处 模板处 最大流模板 处理重边的+(优化) #include<bits/stdc++.h> using namespace std; ; const int INF = 0x ...
- MS SqlServer 随机查询并随机排序
MS SqlServer : select top N * from Table1 order by NewId() mySql: SELECT * FROM tableName ORDER BY r ...
- Ubuntu 14.04下MySQL服务器和客户端的安装
下面进行简单的配置 安装完成后通过修改/etc/mysql/my.cnf(此文件为mysql的配置文件).将文件中的binding-address=127.0.0.1注释掉.其它配置根据需要更改. H ...
- Qt中的标准对话框
1. Qt为开发者提供了一些可复用的对话框类型,如QMessageBox,QFileDialog,QPrintDialog, QColorDialog, QInputDialog, QProgress ...
- element -validateField校验提示
<el-form :model="numberValidateForm" ref="numberValidateForm" :rules="ru ...