Skip to content

Commit b98b271

Browse files
committed
influxdb: improve documentation
* alias for accessing the influx shell * how to change configuration settings * how to do maintainance on container refusing to start
1 parent 9cc8533 commit b98b271

File tree

1 file changed

+82
-11
lines changed

1 file changed

+82
-11
lines changed

docs/Containers/InfluxDB.md

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,53 @@ To connect use:
1414
| URL (from other services) | http://influxdb:8086 |
1515
| URL (on the host machine) | http://localhost:8086 |
1616

17+
Open the CLI interactive shell by:
18+
19+
``` console
20+
$ docker exec -it influxdb influx
21+
```
22+
1723
## References
18-
- [Docker](https://hub.docker.com/_/influxdb)
19-
- [Website](https://www.influxdata.com/)
24+
- [InfluxDB documentation](https://docs.influxdata.com/influxdb/v1.8/)
25+
- [Using the InfluxDB image (Docker Hub)](https://hub.docker.com/_/influxdb)
26+
27+
## Configuration
28+
29+
Most
30+
[settings](https://docs.influxdata.com/influxdb/v1.8/administration/config) can
31+
be set using environment variables in `~IOTstack/docker-compose.yml`. These
32+
will override settings in the configuration file.
33+
34+
For instance, if you plan on having lots of data or tags, to prevent influxdb
35+
from using up all your RAM for indexes, add:
36+
```yaml
37+
- INFLUXDB_DATA_INDEX_VERSION=tsi1
38+
```
39+
40+
It's not recommended that you change the `influxdb.conf`-configuration file.
41+
But if you absolutely need to, you should to export it as a persistent volume
42+
(otherwise every update/recreate will undo your changes). To do this, edit
43+
`docker-compose.yml` and under influxdb's `volumes:` add:
44+
45+
```yaml
46+
- ./volumes/influxdb/config:/etc/influxdb
47+
```
48+
And then recreate the container: `docker-compose up -d influxdb`
2049

2150
## Setup
2251

52+
To install helper alias `influx` that opens the influx console and displays
53+
times as human-readable:
54+
55+
``` console
56+
$ echo "alias iotstack_influx='docker-compose -f ~/IOTstack/docker-compose.yml \
57+
exec influxdb influx -precision=rfc3339'" >> ~/.profile
58+
$ source ~/.profile
59+
```
60+
2361
To access the influx console, show current databases and database measurements:
2462
```
25-
pi@raspberrypi:~/IOTstack $ docker-compose exec influxdb bash
26-
root@6bca535a945f:/# influx
63+
pi@raspberrypi:~ $ iotstack_influx
2764
Connected to http://localhost:8086 version 1.8.10
2865
InfluxDB shell version: 1.8.10
2966
> show databases
@@ -49,6 +86,9 @@ To create a new database and set a limited retention policy, here for instance
4986
any data older than 52 weeks is deleted:
5087

5188
```
89+
$ iotstack_influx
90+
Connected to http://localhost:8086 version 1.8.10
91+
InfluxDB shell version: 1.8.10
5292
> create database mydb
5393
> show retention policies on mydb
5494
name duration shardGroupDuration replicaN default
@@ -79,24 +119,55 @@ on your card. The goal is to avoid writing lots of small changes targeting the
79119
same physical blocks. Here are some tips to mitigate SD-card wear:
80120

81121
* Don't use short retention policies. This may mask heavy disk IO without
82-
increasing disk space usage. Depending on the file system used, new data may
83-
be written to the same flash blocks that were freed by expiration, wearing
84-
them out.
122+
increasing disk space usage. Depending on the flash card and file system
123+
used, new data may be re-written to the same blocks that were freed by the
124+
expiration, wearing them out.
85125
* Take care not to add measurements too often. If possible no more often than
86-
once a minute. Add all measurements in one operation.
126+
once a minute. Add all measurements in one operation. Even a small write
127+
will physically write a whole new block and erase the previously used block.
87128
* Adding measurements directly to Influxdb will cause a write on every
88129
operation. If your client code can't aggregate multiple measurements into one
89130
write, consider routing them via Telegraf. It has the
90131
`flush_interval`-option, which will combine the measurements into one write.
91132
* All InfluxDB queries are logged by default and logs are written to the
92-
SD-card. To disable this, add to docker-compose.yml, next to the other
133+
SD-card. To disable this, add into docker-compose.yml, next to the other
93134
INFLUXDB_\* entries:
94-
```
135+
```yaml
95136
- INFLUXDB_DATA_QUERY_LOG_ENABLED=false
96137
- INFLUXDB_HTTP_LOG_ENABLED=false
97138
```
98139
This is especially important if you plan on having Grafana or Chronograf
99-
displaying up-to-date data on a dashboard.
140+
displaying up-to-date data on a dashboard, making queries all the time.
141+
142+
## Maintanance when container refuses to start
143+
144+
Sometimes you need start the container without starting influxdb to access
145+
its maintenance tools. Usually when influx crashes on startup.
146+
147+
Add a new line below `influxdb:` to your docker-compose.yml:
148+
```yaml
149+
influxdb:
150+
entrypoint: sleep infinity
151+
```
152+
153+
Recreate the container using the new entrypoint:
154+
``` console
155+
pi@raspberrypi:~/IOTstack $ docker-compose up -d influxdb
156+
Recreating influxdb ... done
157+
```
158+
159+
Now it should start and you can get a shell to poke around and try the
160+
influx_inspect:
161+
``` console
162+
$ docker exec -it influxdb bash
163+
root@5ecc8536174f:/# influx_inspect
164+
Usage: influx_inspect [[command] [arguments]]
165+
```
166+
You may need to do `apt-get update` and `apt-get install` some tools you need.
167+
The container is pretty bare-bones by default.
168+
169+
Of course remove the custom entrypoint and "up -d" again to test if your fixes
170+
worked.
100171

101172
## Old-menu branch
102173
The credentials and default database name for influxdb are stored in the file called influxdb/influx.env . The default username and password is set to "nodered" for both. It is HIGHLY recommended that you change them. The environment file contains several commented out options allowing you to set several access options such as default admin user credentials as well as the default database name. Any change to the environment file will require a restart of the service.

0 commit comments

Comments
 (0)