Influxdb, which can be divided into three main categories: time (time), tag (string), and other member fields. While series is a measurement to hold the policy and tag set composition; This tutorial introduces some of these concepts

1. tag

The KV pair that records metadata in the influxDB data structure does not need to exist. The tag key/value is a string type and an index is established. Therefore, the query efficiency based on tag is higher than that based solely on field. Subsequent SQL will also discover that some queries can only be based on tags

The key to refine

  • Tag Key /value: a string
  • There is an index

The syntax for a common query tag is as follows

show tag keys on <database> from <measurement>
Copy the code

Here is a practical example, as the insert statement will say, of the data we inserted, specifying name as tag and the other three as fields

> insert yhh,name= age=26,id=10,blog="http://blog.hhui.top"> select * from yhh name: Yhh time age blog ID name ---- --- ---- -- ---- 1563888301725811554 26 http://blog.hhui.top 10 一 gray > show tag keys from yhh name: yhh tagKey ------ nameCopy the code

The following describes how to obtain tag keys and how to query tag values

show tag values on <database> from <measurement> with KEY [ [<operator> "<tag_key>" | <regular_expression>] | [IN ("<tag_key1>"."<tag_key2")]] [WHERE <tag_key> <operator> ['<tag_value>' | <regular_expression>]] [LIMIT_clause] [OFFSET_clause]
Copy the code
  • With key followed by a query condition, must exist, such as query exchange rate table, base_symbol which
  • The hyphen can be equal to=Is not equal to:! =.<>, a regular:= ~.! ~
> show tag values from currency_rate with key="base"
name: currency_rate
key  value
---  -----
base AUD
base CAD
base CNY
base DKK
base EUR
base GBP
base HKD
base IDR
base INR
base JPY
base KRW
base NZD
base PHP
base PLN
base RUB
base SGD
base THB
base TRY
base UAH
base USD
Copy the code

2. field

Member can also be understood as data in a record that does not need to be indexed. Generally speaking, it is unlikely to participate in query statement construction and can be set as field

Different from a tag, a field has several features

  • The types can be floating point, string, or integer
  • No index

The statement to view the field key is as follows

show field keys on <database> from <measurement>
Copy the code

Here is a demonstration of the viewing posture

> show field keys from yhh
name: yhh
fieldKey fieldType
-------- ---------
age      float
blog     string
id       float
Copy the code

3. point

Docs.influxdata.com/influxdb/v1…

In InfluxDB, you can simply interpret a single record in mysql as a point, which consists of four components

  • measurement
  • tag set
  • field set
  • timestamp

Each point is unique according to timestamp + series.

What do you mean by point? Since influxDB is a temporal database, simply speaking, each data is a point on the time axis, which is strongly correlated with time. The tags are used for retrieval, the fields are used to record some information, and the measurements are used to gather the same type of data

4. series

Docs.influxdata.com/influxdb/v1…

What about uniqueness of point, what about series?

The official explanation is:

The collection of data in the InfluxDB data structure that share a measurement, tag set, and retention policy.

Measurement + tags set + Retention policy in influxDB

Looking directly at the definition can be confusing, but the official command to view series is as follows

show series on <database> from <measurement>
Copy the code

Here are a few examples to help illustrate

> insert yhh,name= age=26,id=10,blog="http://blog.hhui.top"> insert yhh,name= age=30,id=11,blog="http://blog.hhui.top"> select * from yhh; name: Yhh Time Age blog ID name ---- --- ---- -- ---- 1563889538654374538 26 http://blog.hhui.top 10 A Gray 1563889547738266214 30 http://blog.hhui.top 11 a gray > show series ontestFrom yhh key -- yhh,name= yhh >Copy the code

We insert two points into the measurement of yhh, but their tags are all the same. When we look at series, we find that there is only one yhh,name= one gray, including measurement and tag set

Let’s try it out. If we add a tag, will the series increase?

< span style = "max-width: 100%; clear: both; min-height: 1em"http://blog.hhui.top"< span style = "max-width: 100%; clear: both; min-height: 1em"http://blog.hhui.top"> select * from yhh name: Yhh Time Age blog ID Name phone ---- --- ---- -- ---- ----- 1563889538654374538 26 http://blog.hhui.top 10 a Gray 1563889547738266214 30 http://blog.hhui.top 11 One ash 1563889704754695002 30 http://blog.hhui.top 11 one ash 2 1563889723440000821 30 http://blog.hhui.top 11 a gray 3 110 > show series ontestFrom yhh key -- yhh,name= gray yhh,name= gray 2 yhh,name= gray 3,phone=110Copy the code

Series is also related to the save policy in the official definition, the first two cases are the default save records, we are now testing in the new save policy

> create retention policy "1D" on test duration 1d replication 1
> insert into "1D"Yhh,name= 4 age=26,id=10,blog="http://blog.hhui.top"> select * from yhh; name: Yhh Time Age blog ID Name phone ---- --- ---- -- ---- ----- 1563889538654374538 26 http://blog.hhui.top 10 a Gray 1563889547738266214 30 http://blog.hhui.top 11 One ash 1563889704754695002 30 http://blog.hhui.top 11 one ash 2 1563889723440000821 30 http://blog.hhui.top 11 一 gray 3 110 > select * from"1D".yhh name: Yhh time age blog ID Name phone ---- --- ---- -- ---- ----- 1563890614849474879 26 http://blog.hhui.top 10 a Gray 4 > show Series key -- yhh,name= gray yhh,name= gray 2 yhh,name= gray 3,phone=110 yhh,name= gray 4Copy the code

Points inserted into the “1D” save policy also form a series: yhh,name= a series 4

Pay attention to

Tag-based WHERE queries are also expected to be supported in show Series, and here is a simple example

show series from yhh where "name" = 'A Grey'Key -- yhh,name= yhh > show series from yhhwherephone ! =' 'Key -- yhh,name= 1,phone=110Copy the code

II. The other

0. Series of blog posts

  • 190721- Whole Sql Series 3: Measurement Tables
  • 190719- Readership RETENTION Policies, Readership Retention Policies, Readership Retention Policies, Readership Retention Policies
  • 190718- Whole Sql Series 1: Database database
  • 190717- Introduction to Installation and READy-to-USE CLI posture
  • 190509-InfluxDb Timestamp is displayed in date format
  • 190506-InfluxDB Configuration modified
  • 190505-Rights management for the InfluxDB
  • 180727- Backup and restore policies for the sequential database InfluxDB
  • Summary of basic concepts of 180726-InfluxDB
  • Installation and Simple use summary of 180725-INFLUxDB-V1.6.0

Refer to the post

  • Docs.influxdata.com/influxdb/v1…
  • Docs.influxdata.com/influxdb/v1…

1. A gray Blog:liuyueyi.github.io/hexblog

A gray personal blog, recording all the study and work in the blog, welcome everyone to go to stroll

2. Statement

As far as the letter is not as good as, has been the content, purely one’s own words, because of the limited personal ability, it is hard to avoid omissions and mistakes, such as finding bugs or better suggestions, welcome criticism and correction, not grudging gratitude

  • Micro Blog address: Small Gray Blog
  • QQ: a gray /3302797840

3. Scan attention

A gray blog