文档

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 = "

协议

  1. influxdb的数据由时间序列(time series)组织,包含度量值(measurement),像cpu_load, temperature等等。2
  2. 时间序列有0个或多个记录点(points),每个指标一个离散样本。
  3. points包含timestamp和measurement,至少一个key-value域(fields),例如 value=0.64 or 15min=0.78,0或多个key-value标签(tags),包含元数据(metadata),例如host=server01,region=EMEA,dc=Frankfurt。
  4. 从概念上讲,可以把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使用的更多相关文章

  1. 时序数据库InfluxDB安装及使用

    时序数据库InfluxDB安装及使用 1 安装配置 安装 wget https://dl.influxdata.com/influxdb/releases/influxdb-1.3.1.x86_64. ...

  2. 时序数据库InfluxDB

    在系统服务部署过后,线上运行服务的稳定性是系统好坏的重要体现,监控系统状态至关重要,经过调研了解,时序数据库influxDB在此方面表现优异. influxDB介绍 时间序列数据是以时间字段为每行数据 ...

  3. 时序数据库InfluxDB(I)- 搭建与采集信息demo操作

    搭建环境:vmware workstation pro15.5.0, ubuntu18.04.3 实践时间:2019.10.12-10.27 (一)时序数据库InfluxDB准备 (1)安装 曾出现问 ...

  4. Spring Boot中使用时序数据库InfluxDB

    除了最常用的关系数据库和缓存之外,之前我们已经介绍了在Spring Boot中如何配置和使用MongoDB.LDAP这些存储的案例.接下来,我们继续介绍另一种特殊的数据库:时序数据库InfluxDB在 ...

  5. 简析时序数据库 InfluxDB

    时序数据基础 时序数据特点 时序数据TimeSeries是一连串随时间推移而发生变化的相关事件. 以下图的 CPU 监控数据为例,同个 IP 的相关监控数据组成了一条时序数据,不相关数据则分布在不同的 ...

  6. 部署rfc5766-turn-server--谷歌推荐的开源穿透服务器 [复制链接]

    谷歌推荐的开源穿透服务器,包含trun和stun服务,主页:https://code.google.com/p/rfc5766-turn-server/(个人觉得可以利用这个来进一步搭建VPN,有兴趣 ...

  7. 搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用

    搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用 分类: linux编译相关2013-01-05 21:38 17983人阅读 评论(24) 收藏 举报 先下载 ...

  8. Windows下免费、开源邮件服务器hMailServer

    Windows下免费.开源邮件服务器hMailServer 一.Windows下搭建免费.开源的邮件服务器hMailServer 二.邮件服务器hMailServer管理工具hMailServer A ...

  9. 开源流媒体服务器SRS学习笔记(1) - 安装、推流、拉流

    SRS(Simple RTMP Server)  是国人写的一款非常优秀的开源流媒体服务器软件,可用于直播/录播/视频客服等多种场景,其定位是运营级的互联网直播服务器集群. 一.安装 官网提供了3种安 ...

随机推荐

  1. 02 Django web开发-html简介

    软件开发和网络 HTML是用于创建网页的标准标记语言 -HTML指的是超文本标记语言 -HTML不是一种编程语言,二十一种标记语言 -是用来描述网页的一种语言 -HTML描述使用标记的网页的结构 -是 ...

  2. HDU3555 区间的数里面有49的个数(数位dp)

    题目:区间的数里面有49的个数 分析: dp[pos][0]:长度为pos的数中,不包含49的,前一位不为4的有多少个:dp[pos][1]:长度为pos的数中,不包含49的,前一位为4的有多少个:d ...

  3. Educational Codeforces Round 3 B

    B. The Best Gift time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  4. javscript---Bom 和Dom

    JavaScript分为 ECMAScript,DOM,BOM. ECMA javascript标准语法 BOM(Browser Object Model)是指浏览器对象模型,它使 JavaScrip ...

  5. Python中的None与 NULL(即空字符)的区别

    None是Python的特殊类型,NoneType对象,它只有一个值None. 它不支持任何运算也没有任何内建方法. None和任何其他的数据类型比较永远返回False. None有自己的数据类型No ...

  6. 3.centos7 常用防火墙命令(转)

    1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status f ...

  7. Unable to verify your data submission.加入了_csrf也报400错误的解决

    <input type="hidden" name="_csrf" value="<?=Yii::$app->request-> ...

  8. Big Data Opportunities and Challenges(by周志华)论文要点

    大数据环境下的机器学习 三种误解:模型不再重要(大量数据上复杂模型依然提升显著,大数据是的复杂模型充分利用数据且难以过拟合),相关性就足够了(因果关系重要性无法被替代),以前的研究方向不再重要(高性能 ...

  9. vue进阶 --- 实例演示

    这篇博客将通过一个实例来对vue构建项目的过程有一个了解. 主要用到的知识点如下所示: vue-router 2.0路由配置 router-view 和 router-link的使用 transiti ...

  10. 动态资源不缓存 filter

    package com.itheima.web.filter; import java.io.IOException; import javax.servlet.Filter; import java ...