A lightweight Spring Boot telemetry ingestion system that consumes real-time sensor data over MQTT, processes it, and stores it in TimescaleDB for visualization and analysis using Grafana. Note- The Sensor part is present in another repository - https://github.com/atulsingh1704/sensor-emulator The repository also includes:
- An Eclipse Mosquitto broker
- A sensor emulator for local testing and load simulation
- A Grafana dashboard for multi-sensor monitoring
This project demonstrates backend engineering, distributed systems, containerization, and observability.
To be noted this is the backend part i have created a project sensor emulator to create a fake sensor and its docker file i have made a i mage and commands mentioned run 5 containers of that emulator making 5 sensors . The backend is build to manage 5000 devices hitting every sec.
- π‘ MQTT-based ingestion using Mosquitto as it is used in IoT devices
- π§ Spring Boot backend for telemetry processing and using available Spring Boot librarires for Mqtt communication.
- π TimescaleDB (PostgreSQL) for time-series storage
- π Grafana dashboards with multi-sensor filtering
- π Dockerized sensor emulator for realistic testing
- π³ Fully containerized with Docker & Docker Compose
Size of the video is big so to see the project download the video althought it shows how grafana is being utilized and the backend working.
Dockerfileβ multi-stage build for the Spring Boot applicationdocker-compose.ymlβ services:- Mosquitto (MQTT broker)
- TimescaleDB (PostgreSQL)
- Grafana
- Telemetry Engine (Spring Boot)
mosquitto/config/β broker configurationdata/,log/
sensor-emulator/β Dockerized Java-based sensor simulatorsrc/β Spring Boot source code
- Docker Engine & Docker Compose (recommended)
- OR Java 17+ & Maven (for local builds)
- (Optional) Docker Hub account for pushing images
The sensor emulator simulates multiple electrical sensors and publishes telemetry to MQTT topics:
energy/sensor/{sensor_id}
| Variable | Description | Example |
|---|---|---|
SENSOR_ID |
Unique sensor identifier | device-001 |
INTERVAL_MS (optional) |
Publish interval | 1000 |
docker run -d \
--network=host \
-e SENSOR_ID=device-001 \
sensor-emulator:slimdocker compose up -dFrom the project root:
# build with Maven
./mvnw clean package -DskipTests
# run locally
java -jar target/telemetry-engine-0.0.1-SNAPSHOT.jarThe project uses a multi-stage Dockerfile:
- Build stage β Maven
- Runtime stage β slim JRE
# build image
docker build -t atulsingh17/telemetry-engine:latest .
# test run
docker run --rm -p 8080:8080 atulsingh17/telemetry-engine:latestdocker login
docker push atulsingh17/telemetry-engine:latestThe included docker-compose.yml starts all required services together.
# build and start
docker-compose up --build
# run in background
docker-compose up --build -d
# stop and remove
docker-compose down
# view logs
docker-compose logs -f telemetry-appDatabase Name: smartgrid
CREATE TABLE telemetry (
timestamp TIMESTAMPTZ NOT NULL,
sensor_id TEXT NOT NULL,
voltage DOUBLE PRECISION,
current DOUBLE PRECISION,
temperature DOUBLE PRECISION
);SELECT create_hypertable('telemetry', 'timestamp', if_not_exists => TRUE);- Query:
SELECT DISTINCT sensor_id FROM telemetry ORDER BY sensor_id; - Multi-value: β
- Include All: β
- All value:
.*
SELECT
timestamp AS "time",
voltage,
sensor_id
FROM telemetry
WHERE
$__timeFilter(timestamp)
AND sensor_id ~ '(${sensor_id:regex})'
ORDER BY timestamp ASC;- π Voltage per sensor (time series)
- π‘ Temperature per sensor (time series)
- π’ Latest voltage & temperature (stat panels)
- π Latest reading per sensor (table)
β οΈ Voltage spike detection
| Service | Port |
|---|---|
| Spring Boot App | 8080 |
| Mosquitto (MQTT) | 1883 |
| Mosquitto (WebSocket) | 9001 |
| TimescaleDB | 5432 |
| Grafana | 3000 |
If docker build fails, try pulling base images manually:
docker pull maven:3.9.4-openjdk-17
docker pull eclipse-temurin:17-jreIf services are slow to start, check logs:
docker-compose logsRecommended pipeline:
- Build Maven artifact
- Build Docker image
- Tag with version / commit SHA
- Push to Docker Hub
- Deploy via:
docker-compose pull
docker-compose up -d- MQTT-based telemetry ingestion
- Time-series data modeling
- Dockerized microservices
- Observability with Grafana
- Scalable sensor simulation
- Backend system design
Atul Singh Backend / Systems Engineering Java Β· Spring Boot Β· Docker Β· Time-Series Databases
This project is provided as-is.
Add a license file if you plan to release it publicly.
