Skip to content

Instantly share code, notes, and snippets.

@artsok
Forked from dariubs/influxdb.md
Created September 29, 2019 13:12
Show Gist options
  • Save artsok/6a189d435d0eb0c9b0f12e57a40f1209 to your computer and use it in GitHub Desktop.
Save artsok/6a189d435d0eb0c9b0f12e57a40f1209 to your computer and use it in GitHub Desktop.
influxdb cheatsheet

Influxdb cheatsheet

Install with docker

Pull the latest version of influxdb official image :

docker pull influxdb

Or pull specific version of influxdb official image :

docker pull influxdb:<version>

Create a directory for influxdb data volume and change directory to it:

mkdir ~/influxtest && cd ~/influxtest

Run influxdb container:

docker run --name influxtest -d -p 8086:8086 \
      -v $PWD:/var/lib/influxdb \
      influxdb

For run with custom config file :

First generate default configuration file :

docker run --rm influxdb influxd config > influxdb.conf

If you want to enable user authentication on http, enable auth-enabled option in config file:

[http]
  ...
  auth-enabled = true
  ...

Then create an admin user :

docker run --rm --link=influxtest -it influxdb influx -host influxtest -execute "CREATE USER myname WITH PASSWORD '123456' WITH ALL PRIVILEGES"

Then run the container:

docker run --name influxtest -d -p 8086:8086 \
      -v $PWD:/var/lib/influxdb \
      -v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
      influxdb -config /etc/influxdb/influxdb.conf

Influxdb CLI

Run influxdb cli client in another container linked to influxtest container:

docker run --rm --link=influxtest -it influxdb influx -host influxtest

Query In CLI

If you enable user authentication, authenticate your user first:

auth

Create a new database:

CREATE DATABASE <dbname>

Show list of databases:

SHOW DATABASES

Use a database:

USE <dbname>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment