Postgresql database monitoring experiment 02-influxDB basics

Postgresql database monitoring experiment 02-influxDB basics

1. Basic Concepts

1) database – database, this is the same database concept as the traditional database.

2) measurement – ​​data table. In InfluxDB, measurement is the role of table, which is consistent with the role of table in traditional databases.

1) tag-tag, in InfluxDB, tag is a very important part, table name + tag together as the index of the database, in the form of "key-value".

2) field-data, field is mainly used to store data, and is also in the form of "key-value".

3) timestamp-timestamp, as a time-series database, timestamp is the most important part in InfluxDB, you can specify it when inserting data or leave it blank for the system to specify.

Note: When inserting new data, tag, field and timestamp are separated by spaces.

4) series-series, all the data in the database need to be displayed by chart, and this series represents the data in this table, you can draw a few lines on the chart.

5) Retention policy-data retention policy, you can define the length of data retention, each database can have multiple data retention policies, but only one default policy. .

6) Point-point, which represents the data of a field under certain conditions at a certain time in each table, because it is a point reflected on the chart, so it is called point.

Basic operation

Enter the Influx command interface:

[root@localhost ~]# influx
Connected to http://localhost:8086 version 1.7.9
InfluxDB shell version: 1.7.9
> 

Database operations

Display the database:

> show databases
name: databases
name
----
_internal
telegraf

Create the database:

> create database dba_test
> show databases
name: databases
name
----
_internal
telegraf
dba_test

Delete the database:

> drop database dba_test
> show databases
name: databases
name
----
_internal
telegraf

Use the database:

> use telegraf
Using database telegraf

Data table operation

Show all tables:

> show measurements
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system

Create table: You
can only create a new table by insert:
Syntax:
insert + measurement + "," + tag = value, tag = value + + field = value, field = value
field If it is a string type, you need to add quotation marks

insert measurement_name,tag01=t1,tag02=t2 field01="f1",field02=2,field03="f3"

View the table:

> select * from measurement_name
name: measurement_name
time                field01 field02 field03 tag01 tag02
----                ------- ------- ------- ----- -----
1574474709382296133 f1      2       f3      t1    t2

Delete the table:

> drop measurement_name

Data manipulation

Insert data:

> insert measurement_name,tag01=t11,tag02=t22 field01="1",field02=22,field03="3"
> select * from measurement_name
name: measurement_name
time                field01 field02 field03 tag01 tag02
----                ------- ------- ------- ----- -----
1574474709382296133 f1      2       f3      t1    t2
1574475001546325508 1       22      3       t11   t22

Because it is a time series database, you cannot modify or delete data.

Published 136 original articles · Like 58 · Visits 360,000+

Guess you like

Origin blog.csdn.net/sunbocong/article/details/103205072