Backend to store, visualize and explore sensor data collected by MultisensorLoRaNodes and PaxCounter
Consists of Telegraf, Grafana and InfluxDB running in Docker on on a Linux system
-
Clone the repository
cd ~ git clone https://github.com/WullT/TGIBackend.git
-
Install Docker and Docker-Compose (this may take a while)
sh ~/TGIBackend/scripts/install_docker_and_dc.sh
-
Make a copy of the example config files
sh ~/TGIBackend/scripts/prepare_docker.sh
-
Update credentials for InfluxDB and Grafana
nano ~/TGIBackend/docker/.env
Name Description INFLUXDB_ADMIN_USERNAME Username for InfluxDB admin user INFLUXDB_ADMIN_PASSWORD Password for InfluxDB admin user INFLUXDB_READ_USER Username for InfluxDB user with read permissions on INFLUXDB_DB
INFLUXDB_READ_USER_PASSWORD Password for InfluxDB user with read permissions on INFLUXDB_DB
INFLUXDB_WRITE_USERNAME Username for InfluxDB user with write permissions on INFLUXDB_DB
INFLUXDB_WRITE_USER_PASSWORD Password for InfluxDB user with write permissions on INFLUXDB_DB
INFLUXDB_DB Name of the database to store data GF_USERNAME Username for Grafana admin user GF_PASSWORD Password for Grafana admin user -
Update
telegraf.conf
nano ~/TGIBackend/docker/telegraf/telegraf.conf
Change following fields:
Section Field Set to [[outputs.influxdb]]
database Name of the InfluxDB database ( INFLUXDB_DB
)[[outputs.influxdb]]
username INFLUXDB_WRITE_USERNAME
[[outputs.influxdb]]
password INFLUXDB_WRITE_USER_PASSWORD
[[inputs.mqtt_consumer]]
(first)username TTN MQTT Integration username [[inputs.mqtt_consumer]]
(first)password TTN MQTT Integration password (API Key) [[inputs.mqtt_consumer]]
(second)username Local MQTT ruser username (choose one) [[inputs.mqtt_consumer]]
(second)password Local MQTT ruser password (choose one) -
Reboot
-
Run the applications
cd ~/TGIBackend/docker docker-compose up -d
-
Update Mosquitto user credentials
- Generate passwords for
admin
andwuser
(you have already defined a password forruser
in step Updatetelegraf.conf
)docker-compose exec mosquitto mosquitto_passwd -b /mosquitto/config/password.txt admin ADMIN_PASSWORD docker-compose exec mosquitto mosquitto_passwd -b /mosquitto/config/password.txt ruser RUSER_PASSWORD docker-compose exec mosquitto mosquitto_passwd -b /mosquitto/config/password.txt wuser WUSER_PASSWORD
- Generate passwords for
-
Restart the applications
cd ~/TGIBackend/docker docker-compose restart
If you want to access Grafana and the MQTT Broker over the internet, you can use a secure tunnel like Yaler, Pagekite or ngrok
- Open a webbrowser and go to
http://<your-backend-host-ip>:3000
- Login with your Grafana admin credentials
- Go to Configuration → Data sources → Add data source
- Select InfluxDB
- Set
URL
tohttp://influxdb:8086
- In the section InfluxDB Details, enter the database name (
INFLUXDB_DB
) and the credentials for InfluxDB Read User (INFLUXDB_READ_USER
,INFLUXDB_READ_USER_PASSWORD
) - Click Save & test