Skip to content

Repository files navigation

Edge Device Monitoring Service

Small IoT/edge project in Go.

What this project demonstrates

  • MQTT telemetry flow: device-simulator -> mosquitto -> edge-service
  • Edge-side telemetry validation and anomaly alerts (temperature > 8C)
  • HTTP API for health and current state
  • Reliability feature: local buffering + retry forwarding when backend is unavailable
  • Minimal Kubernetes deployment for all components

Architecture

device-simulator
    |
    | MQTT publish (QoS 1)
    v
mosquitto broker
    |
    | MQTT subscribe (devices/+/telemetry)
    v
edge-service
  - validate telemetry
  - detect alerts
  - expose HTTP API
  - forward to backend with local buffer/retry
    |
    v
mock-backend

Local run (Go only)

Start services in this order.

Terminal 1 (broker):

docker run -d --name mosquitto -p 1883:1883 \
  -v "$(pwd)/infra/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro" \
  eclipse-mosquitto:2

Terminal 2 (mock backend):

go run ./cmd/mock-backend

Terminal 3 (edge service):

BACKEND_INGEST_URL=http://localhost:9999/ingest go run ./cmd/edge-service

Terminal 4 (device simulator):

go run ./cmd/device-simulator

Useful API checks

curl -s http://localhost:8080/health
curl -s http://localhost:8080/devices
curl -s http://localhost:8080/alerts
curl -s http://localhost:8080/buffer
curl -s "http://localhost:9999/events?limit=5"

Reliability behavior

  • If backend forwarding fails, edge-service stores events in a local JSONL buffer.
  • A periodic flush retries buffered events.
  • GET /buffer shows queue size and buffer file path.

Kubernetes (minimal local setup)

Manifests are in k8s/:

  • 00-namespace.yaml
  • 01-configmap.yaml
  • 02-mosquitto.yaml
  • 03-mock-backend.yaml
  • 04-edge-service.yaml
  • 05-device-simulator.yaml

Apply:

kubectl apply -f k8s/
kubectl get pods -n edge-monitoring
kubectl get svc -n edge-monitoring

If your cluster cannot see local Docker images, load/tag them first. Example for kind:

kind load docker-image edgedevicemonitoringservice-edge-service:latest
kind load docker-image edgedevicemonitoringservice-device-simulator:latest
kind load docker-image edgedevicemonitoringservice-mock-backend:latest

Port-forward for local checks:

kubectl port-forward -n edge-monitoring svc/edge-service 8080:8080
kubectl port-forward -n edge-monitoring svc/mock-backend 9999:9999

Then test:

curl -s http://localhost:8080/health
curl -s http://localhost:8080/devices
curl -s http://localhost:8080/buffer
curl -s "http://localhost:9999/events?limit=5"

Cleanup:

kubectl delete namespace edge-monitoring

Troubleshooting

  • lookup mock-backend ... no such host in edge-service:
    • mock backend may be down; restart go run ./cmd/mock-backend.
  • Port conflicts (1883, 8080, 9999):
    • stop old containers/processes and restart.
  • Broker cleanup:
    docker rm -f mosquitto

Current endpoints

Edge service:

  • GET /health
  • GET /devices
  • GET /alerts
  • GET /buffer

Mock backend:

  • GET /health
  • POST /ingest
  • GET /events?limit=20

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages