Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The basic operation of InfluxDB for InfluxDB learning

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

InfluxDB is an open source distributed database of timing, events, and metrics.

It is written in Go language without external dependency. Its design goal is to achieve distributed and horizontal scaling.

It has three main characteristics:

1. Time Series (time series): you can use time-related functions (such as maximum, minimum, summation, etc.)

2. Metrics (Metrics): you can calculate large amounts of data in real time.

3. Eevents (event): it supports arbitrary event data

Characteristics

Schemaless (unstructured), which can be any number of columns

Scalable

Min, max, sum, count, mean, median a series of functions to facilitate statistics

Native HTTP API, built-in http support, read and write using http

Powerful Query Language is similar to sql

Built-in Explorer comes with management tools

After installing influxdb, log in to the database through the terminal, http api over 8086, page 8083

[root@mycat ~] # inf

Influx influx_inspect influx_tsm infocmp infotocap

Influxd influx_stress info infokey

Log in to the terminal through influx

[root@mycat ~] # influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 0.13.0

InfluxDB shell version: 0.13.0

1. Creating a database, pay attention to the case of keywords

> CREATE DATABASE mydb

> SHOW DATABASES

Name: databases

-

Name

Telegraf

_ internal

Mytab

Mydb

2. Switch libraries, and some keywords are not so standard.

> use mydb

Using database mydb

> USE mydb

Using database mydb

3. Writing and exploring data, the basic format is required to write a piece of data

1. The entity object used by a short primer on the datastore# to store data, which is equivalent to the table name of relational data.

Data in a time series database (influxDB) is an organized time series containing a measured value (that is, a field in RMDB), such as cpu_load or temperature in INFLUXDB

Points are written to InfluxDB using the Line Protocol, which follows the following format:

[, =.] = [, =.] [unix-nano-timestamp]

The following lines are all examples of points that can be written to InfluxDB:

Cpu,host=serverA,region=us_west value=0.64

Payment,device=mobile,product=Notepad,method=credit billed=33,licenses=3i 1434067467100293230

Stock,symbol=AAPL bid=127.46,ask=127.48

Temperature,machine=unit42,type=assembly external=25,internal=37 1434067467000000000

These three examples are written as follows:

There is no explicit statement to create a new table in InfluxDB, so you can only create a new table by means of insert data. As follows:

Insert disk_free,hostname=server01 value=442221834240i 1435362189575692182

Where disk_free is the table name, hostname is the index, value=xx is the record value, there can be multiple record values, and finally the specified time

> insert cpu,host=serverA,region=us_west value=0.64

> select host,region, value from cpu # # the official way of writing is to quote these measurements

Name: cpu

-

Timehostregionvalue

1481203149917071248serverAus_west0.64

Insert disk_free,hostname=server01 value=442221834240i 1435362189575692182

In this statement, disk_free is the table name, hostname=server01 is tag, belongs to the index, and value=xx is field, which can be written and defined at will.

A point with the measurement name of cpu and tags host and region has now been written to the database, with the measured value of 0.64.

Another type of data store, in the same measurement two fields:

The same measurement contains data of two field types

INSERT temperature,machine=unit42,type=assembly external=25,internal=37

> select * from temperature

Name: temperature

-

Timeexternalinternalmachinetype

14812037975306309012537unit42assembly

Delete a measure

Delete from cpu

Methods supported by show

CONTINUOUS, DATABASES, DIAGNOSTICS, FIELD, GRANTS, MEASUREMENTS, QUERIES

RETENTION, SERIES, SHARD, SHARDS, STATS, SUBSCRIPTIONS, TAG, USERS

SHOW TAG KEYS FROM "temperature" shows the label of the measure = show create table aa

Influxdb supports regularization

Series operation

Series represents the data in this table, which can be drawn into several lines on the chart. Series is mainly calculated by tags permutation and combination.

Show series from mem

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report