Influxdb containers: Difference between revisions
From wikinotes
(→Usage) |
(→Usage) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 44: | Line 44: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo podman pull docker.io/library/influxdb:latest | sudo podman pull docker.io/library/influxdb:latest | ||
mkdir {data,config} | |||
sudo podman run --rm 'influxdb:2.7' influx config --json > config/config.json | |||
docker run \ | docker run \ | ||
-p 8086:8086 \ | -p 8086:8086 \ | ||
Line 59: | Line 61: | ||
}} | }} | ||
Then access influxdb using any of: | |||
<syntaxhighlight lang="bash"> | |||
# Web UI | |||
# user: user | |||
# pass: password | |||
open 'http://localhost:8086' | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
# CLI | |||
sudo podman exec -ti ${image} /bin/bash | |||
influx ping # test connection | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
# HTTP API | |||
curl 'http://localhost:8086/api/v2' \ | |||
--header 'Authorization: Token token' \ | |||
--header 'Content-Type: application/json' \ | |||
--data-urlencode "db=default" \ | |||
--data-urlencode "q=SELECT * FROM cpu_usage" \ | |||
| jq | |||
</syntaxhighlight> | |||
</blockquote><!-- Usage --> | </blockquote><!-- Usage --> | ||
</blockquote><!-- Docker/Podman --> | </blockquote><!-- Docker/Podman --> |
Latest revision as of 17:24, 10 June 2023
Docker/Podman
Documentation
dockerhub https://hub.docker.com/_/influxdb/ Usage
TODO:
work in progress. 8086 isn't being exposed to host, needs investigation
Containerfile
FROM docker.io/library/influxdb:2.7 ENV DOCKER_INFLUXDB_INIT_MODE setup ENV DOCKER_INFLUXDB_INIT_USERNAME user ENV DOCKER_INFLUXDB_INIT_PASSWORD password ENV DOCKER_INFLUXDB_INIT_ORG org ENV DOCKER_INFLUXDB_INIT_BUCKET bucket ENV DOCKER_INFLUXDB_INIT_ADMIN_TOKEN token EXPOSE 8086 8086 VOLUME ./data /var/lib/influxdb2sudo podman build . -t influxdb sudo podman run localhost/influxdb
adhoc/cli usage
sudo podman pull docker.io/library/influxdb:latest mkdir {data,config} sudo podman run --rm 'influxdb:2.7' influx config --json > config/config.json docker run \ -p 8086:8086 \ -v $PWD/data:/var/lib/influxdb2 \ -v $PWD/config:/etc/influxdb2 \ `# setup authentication` \ -e DOCKER_INFLUXDB_INIT_MODE=setup \ -e DOCKER_INFLUXDB_INIT_USERNAME=my-user \ -e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \ -e DOCKER_INFLUXDB_INIT_ORG=my-org \ -e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \ -e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token \ influxdb:latest
Then access influxdb using any of:
# Web UI # user: user # pass: password open 'http://localhost:8086'# CLI sudo podman exec -ti ${image} /bin/bash influx ping # test connection# HTTP API curl 'http://localhost:8086/api/v2' \ --header 'Authorization: Token token' \ --header 'Content-Type: application/json' \ --data-urlencode "db=default" \ --data-urlencode "q=SELECT * FROM cpu_usage" \ | jq