Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a measurement in InfluxDB

Tags:

influxdb

I am a beginner with InfluxDB and I've read the intro documentation, but cannot find any details on how to create a new measurement. Am I missing something ?

like image 384
borgmater Avatar asked Dec 23 '16 10:12

borgmater


3 Answers

As noted in the comments, to "create" a new measurement you simply insert data into that measurement.

For example

$ influx
> CREATE DATABASE mydb
> USE mydb
Using database mydb
> SHOW MEASUREMENTS
> INSERT cpu,host=serverA value=10
> SHOW MEASUREMENTS
name: measurements
name
----
cpu

> INSERT mem,host=serverA value=10
> SHOW MEASUREMENTS
name: measurements
name
----
cpu
mem
like image 78
Michael Desa Avatar answered Oct 11 '22 06:10

Michael Desa


In INFLUX DB , you cant create empty measurements. You need to add some data as well.

For Example,

INSERT xyz,name=serverA value=10,count=10

This will create a measurement name xyz where
tag keys : name
field keys : value & count

You can check Field and tag keys by executing show field keys or show tag keys.

In the INSERT command, the format is like :
measurement_name,tag keys + value separated by comma Field keys with value separated by comma

eg: INSERT xyz,name=serverA value=10,count=10

In this way, you can create measurement with specifying your required field and tag keys.

like image 37
Nikhil Kumar Agrawal Avatar answered Oct 11 '22 05:10

Nikhil Kumar Agrawal


create database <data base name of your choice>

create user "<username>" with password '<password>'

To see the all databases: SHOW DATABASES

Enter the Database: use <database name>

To see all tables inside the database: SHOW MEASUREMENTS

grant all on <data base name> to <username>

insert data (Here Motionsense is a Measurement which is similar to the table name of SQL): INSERT MotionSense,SensorType=Gyro roll=1.2,yaw=5,pitch=3

See the data of the Measurements: SELECT * FROM "MotionSense"

like image 25
amit singh Avatar answered Oct 11 '22 05:10

amit singh