Skip to content

Instantly share code, notes, and snippets.

@thikade
Last active April 14, 2020 21:49
Show Gist options
  • Save thikade/12de53a818ffe9c0c08505dd96765ea6 to your computer and use it in GitHub Desktop.
Save thikade/12de53a818ffe9c0c08505dd96765ea6 to your computer and use it in GitHub Desktop.
influxdb cheat sheat for cmdline operations

Basics

Reference

SHOW DATABASES
USE "db"

> SHOW MEASUREMENTS     # similar to tables in RDBs
name: measurements
name
----
events
jmeter


> SHOW TAG KEYS FROM "jmeter"
name: jmeter
tagKey
------
application
responseCode
responseMessage
run
statut
transaction


SHOW TAG VALUES FROM jmeter WITH KEY = "responseCode"


> SHOW FIELD KEYS FROM jmeter
name: jmeter
fieldKey   fieldType
--------   ---------
avg        float
count      float
countError float
...

> SHOW SERIES [ON <database_name>] [FROM jmeter] [WHERE <tag_key> <operator> [ '<tag_value>' | <regular_expression>]] 
> SHOW SERIES FROM jmeter WHERE transaction =~ /^TX/

Retention policies

Reference

SHOW RETENTION POLICIES [ ON "db" ]
SHOW SHARDS
SHOW SHARD GROUPS

ALTER RETENTION POLICY autogen ON jmeter DURATION 240d [ SHARD DURATION <duration> ] DEFAULT
CREATE RETENTION POLICY "what_is_time" ON "NOAA_water_database" DURATION 2d REPLICATION 1
DROP RETENTION POLICY <retention_policy_name> ON <database_name>

Backup

Reference

influxd backup [-host <remote-node-IP>:8088 ] -portable -db jmeter  -start 2019-12-24T08:12:23Z  -end  2019-12-31T00:00:00Z  DIRECTORY

Restore into new database

influxd restore -portable -db jmeter /var/lib/influxdb/backups/2020-01-31-jmeter

Restore into existing database

Reference
This is a 2-step procedure:

  1. Restore into temporary db
influxd restore -portable -db jmeter  -newdb jmeter_temp   /var/lib/influxdb/backups/2020-01-31-jmeter
  1. Copy everything from temp db in to original db (will overwrite!)
USE jmeter_temp
SELECT * INTO jmeter..:MEASUREMENT FROM /.*/ GROUP BY *
DROP DATABASE jmeter_temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment