How to create a measurement in InfluxDB

51.1k Views Asked by At

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 ?

4

There are 4 best solutions below

2
On BEST ANSWER

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
0
On

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.

0
On

You cannot create an empty measurement, afaik. Like they said above, if you want one you need to start writing to it and that should take care of creating one along with some data in it.

insert load,app_name=app3,groupname=second,performance=degraded uuid=003,loading=50,frequency=1

In the above, we are using "insert" to write new data into a new measurement called "load". app_name,groupname,performance are 'tags' and uuid,loading,frequency are fields

0
On
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"