Influxdb Use Record

Source: Internet
Author: User
Tags urlencode influxdb

I am a Mac environment

1. Installation

Brew Install Influxdb

When the installation is complete, the default directory is/usr/local/opt/influxdb.

2. After the installation is complete, open the Influxdb service.

$ influxd

This is done in the foreground, when the CTRL + C stop, you can not access, to long-term operation, the use of background execution:

$ influxd &

3. Access Influxdb in the background

$ influx

1) Create a database

> CREATE DATABASE MyDB

2) View the database

> Show Databases
Name:databases
---------------
Name
_internal
MyDB
Test

3) Switch Database
> Use MyDB
Using Database MyDB

4) Create user name, password
> Create user mydb with password ' mydb '

5) View the created user

> Show Users

Useradmin
Heminfalse
Mydbfalse

6) Create a table from INSERT, if you view help, you cannot find the CREATE TABLE ...

> Insert Disk_free,hostname=pg20 value=442221834240i 1435362189575692182

7) View Data sheet

> Show Measurements
Name:measurements
------------------
Name
Disk_free

8) Querying table data

> select * from Disk_free
Name:disk_free
---------------
Timehostnamevalue
1435362189575692182pg20442221834240

9) Delete Table

Drop Measurement Disk_free

10) Delete Database

Drop Database MyDB

Series Operations

The series represents the data in this table, which can be drawn as a few lines on the chart, and series is calculated mainly by the tags permutation combination.

Still not understand.

4.Http API

1) Set up a database

Curl-post http://localhost:8086/query--data-urlencode "q=create DATABASE mydb"

After executing this statement, a database named MyDB is created locally.

2) Delete Database

Curl-post http://localhost:8086/query--data-urlencode "Q=drop DATABASE mydb"

In fact, using the HTTP API is to send the corresponding POST request to the InfluxDB interface.

Send the statement to the server via post.

3) Create a table

Influxdb the use of the HTTP API to add data mainly uses the following format:

Curl-i-xpost ' http://localhost:8086/write?db=mydb '--data-binary ' cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000 '

Description: Db=mydb refers to the use of the MyDB database.

--data-binary is followed by inserting data.

Cpu_load_short is the table name (measurement), and the tag field is host and region, with the values: Server01 and Us-west, respectively.

Field key is a value of 0.64.

The timestamp (timestamp) is specified as 1434055562000000000.

This inserts a piece of data into the Cpu_load_short table of the MyDB database.

Where the DB parameter must specify a database name that already exists in the database, the format of the data body conforms to the INFLUXDB specification format, first the table name, followed by tags, then field, and finally the timestamp. tags, field, and timestamp are separated by a space.

4) inserting more than one data

Influxdb adding multiple pieces of data through the HTTP API is similar to adding a single piece of data, such as:

Curl-i-xpost ' http://localhost:8086/write?db=mydb '--data-binary ' Cpu_load_short,host=server02 value=0.67cpu_load_ Short,host=server02,region=us-west value=0.55 1422568543702900257cpu_load_short,direction=in,host=server01, Region=us-west value=2.0 1422568543702900257 '

This statement inserts three data into the table Cpu_load_short of the database MyDB.

The first one specifies the tag as host, the value is Server02, the second specifies the tag as host and region, the values are Server02 and Us-west, the third one specifies the tag direction,host,region, the values are: in, Server01,us-west.

4) Error message

When using the HTTP API, the INFLUXDB responds mainly to the following:

1) 2xx:204 represents no content,200 on behalf of INFLUXDB can receive the request but does not complete the request. Typically, there is an error message in the body body.

2) 4xx:influxdb cannot parse the request.

3) 5xx: System error occurred.

5. Access on the Web page

http://IP:8083

Note, not HTTPS, before access, look carefully before discovering

Influxdb Use Record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.