influxdb简介

Key Concepts key概念
在深入InfluxDB之前,它是很好的熟悉一些数据库的关键概念,这份文档提供了一个温和渐进的介绍这些概念和常用InfluxDB术语
我们在下面提供所有我们将讨论的条款清单,但我们建议从开始阅读本文件完成争取我们最喜欢的时间序列数据库的一个更一般的理解。

database field key field set
field value measurement point
retention policy series tag key
tag set tag value timestamp
Check out the Glossary if you prefer the cold, hard facts.

样本数据
下面引用数据下打印出来。数据是虚构的,但代表了InfluxDB一个可信的设置。它们显示了 butterflies和honeybees be counts((langstroth and perpetua)) in two locations (0 或者 1) 在从2015年8月18日午夜至2015年8月18日在上午06点12分的时间段
假设数据生活在一个数据库名为MY_DATABASE并受到了AUTOGEN保留策略(更多的数据库和保留策略来)
提示:将鼠标悬停在链接工具提示得到与InfluxDB术语和布局熟悉
name: census
-————————————
time butterflies honeybees location scientist
2015-08-18T00:00:00Z 12 23 1 langstroth
2015-08-18T00:00:00Z 1 30 1 perpetua
2015-08-18T00:06:00Z 11 28 1 langstroth
2015-08-18T00:06:00Z 3 28 1 perpetua
2015-08-18T05:54:00Z 2 11 2 langstroth
2015-08-18T06:00:00Z 1 10 2 langstroth
2015-08-18T06:06:00Z 8 23 2 perpetua
2015-08-18T06:12:00Z 7 22 2 perpetua


讨论
现在,你已经看到了InfluxDB一些样本数据本节涵盖这一切意味着什么。
InfluxDB是一个时间序列数据库,所以是有意义的开始与什么是我们一切的根源:
time。在上述数据有一个名为列 time 在InfluxDB所有数据列都有 ,time 存储时间戳和时间戳示出了具有特定数据相关联的日期和时间,在RFC3339 UTC。

接下来的两列,称为butterflies and honeybees 是字段。field keys and field values,Field keys (butterflies and honeybees) are strings and they store metadata; the field key butterflies tells us that the field values 12-7 refer to butterflies and the field key honeybees tells us that the field values 23-22 refer to, well, honeybees.

字段值数据;它们可以是字符串,浮点数,整数或布尔值,而且,由于InfluxDB是一个时间序列数据库,一个字段的值总是与一个时间戳相关联。在样本数据的字段值包括:
12 23
1 30
11 28
3 28
2 11
1 10
8 23
7 22

在上面的数据,field-key and field-value pairs 的集合构成了一个filed set。这里是所有filed set集样本数据:

butterflies = 12 honeybees = 23
butterflies = 1 honeybees = 30
butterflies = 11 honeybees = 28
butterflies = 3 honeybees = 28
butterflies = 2 honeybees = 11
butterflies = 1 honeybees = 10
butterflies = 8 honeybees = 23
butterflies = 7 honeybees = 22

字段是一个需要一块InfluxDB的数据结构 - 你不能没有字段InfluxDB数据
It’s also important to note that fields are not indexed. Queries that use field values as filters must scan all values that match the other conditions条件 in the query.

其结果是,这些查询是不是相对高性能的查询上的标签(更多标签下方)。在一般情况下,字段应不包含共同查询元数据

最后两列中的采样数据,称为location and scientist 是标签 标签是由标签键和标签值的。这两个标签键和标签值作为字符串存储和记录元数据

在样本数据的标签键是location and scientist 标签键 location 有两个变量值:1和2。 标签键 scientist 同样有两个变量值为langstroth and perpetua.


In the data above, the tag set is the different combinations of all the tag key-value pairs. The four tag sets in the sample data are:
location = 1, scientist = langstroth
location = 2, scientist = langstroth
location = 1, scientist = perpetua
location = 2, scientist = perpetua

标记是可选的。你不需要有标签的数据结构,但它通常是一个好方法,利用它们,因为不像字段,标签是可以被索引的 这意味着,在查询标签是速度更快,这标签是理想的用于存储常用-查询的元数据

Why indexing matters: The schema case study Say you notice that most of your queries focus on the values of the field keys honeybees and butterflies:
SELECT * FROM "census" WHERE "butterflies" = 1
SELECT * FROM "census" WHERE "honeybees" = 23

Because fields aren’t indexed, InfluxDB scans every value of butterflies in the first query and every value of honeybees in the second query before it provides a response.
因为字段没有索引,InfluxDB扫描butterflies的每个值 在第一次查询honeybees的每一个值 在第二个查询之前它提供了一个响应
这种行为会伤害查询响应时间 - 尤其是在更大的范围
要优化查询,这可能是有益的重新排列模式,使得字段(butterflies and honeybees) become the tags and the tags (location and scientist) become the fields: name: census

name: census
-————————————
time location scientist butterflies honeybees
2015-08-18T00:00:00Z 1 langstroth 12 23
2015-08-18T00:00:00Z 1 perpetua 1 30
2015-08-18T00:06:00Z 1 langstroth 11 28
2015-08-18T00:06:00Z 1 perpetua 3 28
2015-08-18T05:54:00Z 2 langstroth 2 11
2015-08-18T06:00:00Z 2 langstroth 1 10
2015-08-18T06:06:00Z 2 perpetua 8 23
2015-08-18T06:12:00Z 2 perpetua 7 22

measurement充当标记,字段容器中,时间列,并且measurement名称是存储在相关联的字段的数据的描述 measurement名称是字符串,而且,对于任何SQL用户在那里
measurement在概念上类似于一个表
在样本数据的唯一measurementcensus.
The name census 告诉我们,字段值butterflies and honeybees 记录的数
不是他们的大小,方向,或某种 happiness index

 

单次measurement可以属于不同的保留策略。保留策略描述InfluxDB多久保存数据(DURATION) 和这些数据的多少份被存储在集群中的(cluster) 如果你有兴趣阅读更多有关保留策略,check out Database Management


复制因素不服务的单节点实例目的。
在样本数据,census measurement 的一切属于AUTOGEN保留策略 InfluxDB自动创建保留策略;它具有无限持续时间,并设置到一个复制因素。

现在,你已经熟悉了measurement,标记集,和保留策略是时候来讨论系列。在InfluxDB,a series 是共享的保留策略,measurement和标记组数据的集合。以上数据包括四个series:


Arbitrary series number Retention policy Measurement Tag set
series 1 autogen census location = 1,scientist = langstroth
series 2 autogen census location = 2,scientist = langstroth
series 3 autogen census location = 1,scientist = perpetua
series 4 autogen census location = 2,scientist = perpetua

理解了一系列的概念设计您的架构,并与InfluxDB数据操作的时候是必不可少的。最后,一个点在同一series具有相同时间戳设置字段。例如,这里有一个单点:

name: census
-----------------
time butterflies honeybees location scientist
2015-08-18T00:00:00Z 1 30 1 perpetua

The series in the example is defined by the retention policy (autogen), the measurement (census), and the tag set (location = 1, scientist = perpetua). The timestamp for the point is 2015-08-18T00:00:00Z.

 

所有我们刚刚覆盖存储在数据库中的东西 - 样本数据在数据库MY_DATABASE
一个InfluxDB数据库类似于传统的关系型数据库,并作为用户,保留策略,连续查询的逻辑容器,当然,你的时间序列数据
See Authentication and Authorization and Continuous Queries for more on those topics.

数据库可以有多个用户,连续查询,保留策略和measurement
InfluxDB是一个无模式的数据库,这意味着它很容易随时添加新的measurement,标签和领域。它的设计,使与真棒时间序列数据的工作


#,point,就是某个series的同一个时刻的多个field的value,就组成了一个point;其实就是一般曲线上的一个点。
#,InfluxDb不需要做schema定义,这意味着你可以随意的添加measurements, tags, and fields at any time,

+++++++++++++++++++
#,measurement,就相当于关系数据库中的table,他就是tag,field,time的容器;
#,对于influxDb的measurement来说,field是必须的,并且不能根据field来排序;
#,Tag是可选的,tag可以用来做索引,tag是以字符串的形式存放的;
#,retention policy,保留策略,用于决定要保留多久的数据,保存几个备份,以及集群的策略等;
#,series,a series is the collection of data that share a retention policy, measurement, and tag set,
比如对于下面这个measurement,


比如对于下面这个measurement,
name: census
-————————————
time location scientist butterflies honeybees
2015-08-18T00:00:00Z 1 langstroth 12 23
2015-08-18T00:00:00Z 1 perpetua 1 30
2015-08-18T00:06:00Z 1 langstroth 11 28
2015-08-18T00:06:00Z 1 perpetua 3 28
2015-08-18T05:54:00Z 2 langstroth 2 11
2015-08-18T06:00:00Z 2 langstroth 1 10
2015-08-18T06:06:00Z 2 perpetua 8 23
2015-08-18T06:12:00Z 2 perpetua 7 22

他有下面这四个series
Arbitrary series number Retention policy Measurement Tag set
series 1 default census location = 1,scientist = langstroth
series 2 default census location = 2,scientist = langstroth
series 3 default census location = 1,scientist = perpetua
series 4 default census location = 2,scientist = perpetua

这个其实比较好理解,其实一个series就是一个测点,或者说一条曲线,那么retention policy, measurement, tagset就共同组成了一个定位测点序列的唯一标识。
Understanding the concept of a series is essential when designing your schema and when working with your data in InfluxDB.
#,point,就是某个series的同一个时刻的多个field的value,就组成了一个point;其实就是一般曲线上的一个点。
#,InfluxDb不需要做schema定义,这意味着你可以随意的添加measurements, tags, and fields at any time,
++++++++++++++++++++

特点

schemaless(无结构),可以是任意数量的列
Scalable
min, max, sum, count, mean, median 一系列函数,方便统计
Native HTTP API, 内置http支持,使用http读写
Powerful Query Language 类似sql
Built-in Explorer 自带管理工具


InfluxDb数据库里series对应的是我们常规认识的表,而表里面的一行数据一般都来表示一个对象,而series里面一行数据则是描述的一个point。(没错,就是坐标系里的一个真实的点,所以这个数据库的业务场景就是专门针对这种时间线的数据监控而创作的。)
那么这个点有哪些属性来描述它呢?
timestamp,point的时间戳,
measurement,可以理解为表名,
field,以1~n个key-value来表示,point的值,
tags,以0~n个key-value来表示,point 的属性。
以一个具体的例子来说,现在需要监控1服务器的负载,那么负载(load)就是measurement,此刻的负载值,就是field,该服务器的 ip 就可以作为tags中的一个,也可以不记 ip,因为此时我们的需求只是记录一台服务器而已。

 


专业术语
aggregation
聚合

batch 批量
continuous query (CQ)
连续查询(CQ)

 

posted @ 2016-10-31 23:39  众里寻,阑珊处  阅读(645)  评论(0编辑  收藏  举报
返回顶部