The provided Docker Compose configuration defines an IoT (Internet of Things) stack that consists of several containers working together to build a scalable and efficient data pipeline for IoT applications. The stack includes the following components:
- InfluxDB: The InfluxDB service is responsible for storing time-series data generated by various IoT devices. InfluxDB is a popular time-series database that efficiently handles high-throughput data ingestion and querying.
- Mosquitto: Mosquitto is an MQTT (Message Queuing Telemetry Transport) broker, which serves as a lightweight and efficient messaging protocol for IoT devices to publish and subscribe to data. It facilitates the real-time communication and data exchange among IoT devices and other components of the stack.
- Telegraf: Telegraf acts as an agent to collect and gather data from various sources and send it to InfluxDB. It is used for collecting system metrics, monitoring data, and other relevant information from IoT devices or applications.
- Grafana: Grafana is a powerful data visualization and monitoring tool that connects to InfluxDB to display real-time and historical data in the form of dashboards and graphs. It provides a user-friendly interface for analyzing and understanding the data generated by IoT devices.
The stack utilizes Docker containers for easy deployment and isolation of the services. Each container runs independently and communicates with other services through defined networks. Volumes are used to persist data for InfluxDB and Grafana, ensuring data continuity even if the containers are stopped and restarted.
This stack is written for a Windows machine running Docker with Docker Desktop
docker run -it --rm -v "%cd%/mosquitto/config:/mosquitto/config" eclipse-mosquitto mosquitto_passwd -U /mosquitto/config/passwd
docker-compose up -d
EJBCA is used to provide X.509 certificates for a secure connection between the MQTT Client and the MQTT Broker which is included in the stack
You can finde the certificate and end entity profiles in ./ejbca/profiles
Please make sure to define the IP-adress in the subject alternative name. Otherwise the handshake will fail.
You can generate the P12 files via the Web-RA
To extract the key and cert you can use the shell script in certs/mqtt/extract_key_cert.sh
.
bash extract_key_cert.sh -p <YOUR_P12_FILE>
Copy the broker certificate to the broker machine and rename the cert & key location in
/telegraf/telegraf.toml
andmosquitto/config/mosquitto.conf
You can start a Python test MQTT client which you can find in ./mqtt_client/test_mqtt.py
. It will publish random JSON structured data every 5 seconds to the broker.
InfluxDB (http://localhost:8086)
Open InfluxDB and login via the pre-defined credentials in docker.env
. You can create new secrets and buckets to your needs.
Grafana (http://localhost:3000/grafana)
Login via the predefined credentials. Once you logged in you need to define a Data Source (InfluxDB).
Parameters:
- Query language: Flux
- URL: http://influxdb:8086
- Organization: keyfactor
- Default Bucket: kexfactor_db
- Token: A Token generated with InfluxDB and READ access