开源时序服务器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种安 ...
随机推荐
- angularJs条件查询:
首先需要建立一个输入框进行数据绑定: <div class="box-tools pull-right"> <div class="has-feedba ...
- Web项目和Windows应用程序的配置文件
1.Web项目,配置文件应创建在Web项目下,即使是要把配置文件作为一个单独的文件进行配置(比如log4net.config),也需要把该配置文件放在Web项目下:同理Windows应用程序的化,配置 ...
- UVALive 3645 时序模型
按航班拆点 注意返边的条件 #include<bits/stdc++.h> using namespace std; const int maxn = 1e6+11; const int ...
- redis初识及基本操作
一.redis介绍: 1.Redis是什么: REmote DIctionary Server(远程字典服务器) 是完全开源免费的,用C语言编写的,遵守BSD协议,是一个高性能的(Key-Value) ...
- centos7-网络与防火墙常用命令
1.网络配置 vi /etc/sysconfig/network-scripts/ifcfg-ens33 BOOTPROTO="static" IPADDR=192.168.163 ...
- Python中的数据类型和数据结构
一.数据类型 Python中有六个标准数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionary(字典) 其中,除列表Lis ...
- PHP rand 和 mt_rand
PHP mt_rand() 函数 定义和用法 mt_rand() 使用 Mersenne Twister 算法返回随机整数. 语法 mt_rand(min,max) 说明 如果没有提供可选参数 min ...
- java课后思考题(四)
1. 请运行以下示例代码StringPool.java,查看其输出结果.如何解释这样的输出结果?从中你能总结出什么? 输出结果: 结论: 在Java中,内容相同的字串常量(“Hello”)只保存一份以 ...
- windows系统打开火狐浏览器提示“无法加载你的firefox配置文件”
win7系统自带IE浏览器,还是有部分用户使用不习惯,选择下载第三方浏览器,比如:火狐.谷歌.360浏览器等.最近有Win7系统用户在重新安装火狐浏览器后发现打不开,并提示“无法加载你的firefox ...
- 转 rac中并行 PARALLEL 的设置
sample 1: rac中并 行的设置 https://blog.csdn.net/wll_1017/article/details/8285574 我们的生产库一般在节点一上的压力比较大,在节点二 ...