Skip to content

Commit c614c20

Browse files
committed
influxdb: document basic usage
1 parent 4f52cf0 commit c614c20

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

docs/Containers/InfluxDB.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,104 @@
11
# InfluxDB
2+
A time series database.
3+
4+
InfluxDB has configurable aggregation and retention policies allowing
5+
measurement resolution reduction, storing all added data points for recent data
6+
and only aggregated values for older data.
7+
8+
To connect use:
9+
10+
| Field | Default |
11+
| --------- | ---------- |
12+
| User | nodered |
13+
| Password | nodered |
14+
| URL (from other services) | http://influxdb:8086 |
15+
| URL (on the host machine) | http://localhost:8086 |
16+
217
## References
318
- [Docker](https://hub.docker.com/_/influxdb)
419
- [Website](https://www.influxdata.com/)
520

6-
## Security
21+
## Setup
22+
23+
To access the influx console, show current databases and database measurements:
24+
```
25+
pi@raspberrypi:~/IOTstack $ docker-compose exec influxdb bash
26+
root@6bca535a945f:/# influx
27+
Connected to http://localhost:8086 version 1.8.10
28+
InfluxDB shell version: 1.8.10
29+
> show databases
30+
name: databases
31+
name
32+
----
33+
_internal
34+
telegraf
35+
> use telegraf
36+
Using database telegraf
37+
> show measurements
38+
name: measurements
39+
name
40+
----
41+
cpu
42+
cpu_temperature
43+
disk
44+
diskio
45+
etc...
46+
```
47+
48+
To create a new database and set a limited retention policy, here for instance
49+
any data older than 52 weeks is deleted:
50+
51+
```
52+
> create database mydb
53+
> show retention policies on mydb
54+
name duration shardGroupDuration replicaN default
55+
---- -------- ------------------ -------- -------
56+
autogen 0s 168h0m0s 1 true
57+
> alter retention policy "autogen" on "mydb" duration 52w shard duration 1w replication 1 default
58+
> show retention policies on mydb
59+
name duration shardGroupDuration replicaN default
60+
---- -------- ------------------ -------- -------
61+
autogen 8736h0m0s 168h0m0s 1 true
62+
63+
```
64+
65+
Aggregation, on the other hand, is where you keep your relevant statistics, but
66+
decrease their time-resolution and lose individual data-points. This is a much
67+
more complicated topic and harder to configure. As such it is well outside the
68+
scope of this guide.
69+
70+
71+
## Reducing flash wear-out
72+
73+
SSD-drives have pretty good controllers spreading out writes, so this isn't a
74+
this isn't really a concern for them. But if you store data on a SD-card,
75+
flash wear may cause the card to fail prematurely. Flash memory has a limited
76+
number of erase-write cycles per physical block. These blocks may be multiple
77+
megabytes. You can use `sudo lsblk -D` to see how big the erase granularity is
78+
on your card. The goal is to avoid writing lots of small changes targeting the
79+
same physical blocks. Here are some tips to mitigate SD-card wear:
80+
81+
* 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.
85+
* Take care not to add measurements too often. If possible no more often than
86+
once a minute. Add all measurements in one operation.
87+
* Adding measurements directly to Influxdb will cause a write on every
88+
operation. If your client code can't aggregate multiple measurements into one
89+
write, consider routing them via Telegraf. It has the
90+
`flush_interval`-option, which will combine the measurements into one write.
91+
* 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
93+
INFLUXDB_\* entries:
94+
```
95+
- INFLUXDB_DATA_QUERY_LOG_ENABLED=false
96+
- INFLUXDB_HTTP_LOG_ENABLED=false
97+
```
98+
This is especially important if you plan on having Grafana or Chronograf
99+
displaying up-to-date data on a dashboard.
100+
101+
## Old-menu branch
7102
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.
8103

9104
To access the terminal for influxdb execute `./services/influxdb/terminal.sh`. Here you can set additional parameters or create other databases.

0 commit comments

Comments
 (0)