InfluxDB uselful queries

n

Show all available databases
show databases

nnnn

Use a database e.g mydb
use mydb

nnnn

Show available fields and their type of a a database
show field keys

nnnn

Show series where xyz
show series where "powermeter" = 'xyzzz'

nnnn

Calculate difference between the two latest values of two days
SELECT difference(last(total_kWh)) FROM power_total WHERE time >0 AND "powerMeter" = 'xyz' GROUP BY time(1d)

nnnn

Select the latest entries from a field within a timespan of 2 days
select * from inputs WHERE time >= now() -2d
select * from inputs WHERE time >= now - 10m

nnnn

Write measurement / series in database. Select database first. Tag Keys are not required
INSERT TheMeasurement value=10

nnnn

Select last 10 entries
SELECT * FROM measurement ORDER BY desc LIMIT 10

nnnn

Rename measurement. Not supported by influx. Copy into a new one is they way. To preserve tags, use group by *
SELECT * INTO DestMeasurementCopy from SrcMeasurement GROUP BY *
DROP MEASUREMENT SrcMeasurement

nnnn

Drop a measurement
DROP MEASUREMENT measurement_name

nnnn

Grant user all rights on database
GRANT ALL ON "powermeter" to "myUser"

nnnn

Grant user read rights on database
GRANT READ ON "powermeter" to "myGrafanaUser"

nnnn

Show rights of a user
SHOW GRANTS for myUser

nnnn

Create user with password
CREATE USER "myUser" WITH PASSWORD thepassword

nnnn

Create user with all privileges
CREATE USER admin WITH PASSWORD mypw WITH ALL PRIVILEGES

nnnn

Show all users
SHOW USERS

nnnn

Create a database
CREATE DATABASE powermeter

nnnn

Delete database
DROP DATABASE myDatabase

nnnn

n

Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert