Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/syedhassaanahmed/iot-simulator-influxdb

Simulate synthetic IoT telemetry and ingest into InfluxDB
https://github.com/syedhassaanahmed/iot-simulator-influxdb

Last synced: about 2 months ago
JSON representation

Simulate synthetic IoT telemetry and ingest into InfluxDB

Awesome Lists containing this project

README

        

# iot-simulator-influxdb
![CI](https://github.com/syedhassaanahmed/iot-simulator-influxdb/actions/workflows/ci.yml/badge.svg)

## Why?
>[Do not do in code what can be done in infrastructure](https://rogerjohansson.blog/2017/05/19/do-not-do-in-code-what-can-be-done-in-infrastructure/)

This is certainly not the first time ever that somebody needed to generate syntheric IoT telemetry for InfluxDB. Instead of writing code/scripts to achieve that goal, we can leverage existing tools to do the heavy lifting for us.

## What?
This repo demonstrates how to simulate synthetic IoT telemetry and ingest it into [InfluxDB OSS](https://docs.influxdata.com/influxdb/v2.6/). The telemetry is generated using the [Azure IoT Device Telemetry Simulator](https://github.com/Azure-Samples/Iot-Telemetry-Simulator). The Simulator is capable of sending data to a [Confluent Community Kafka](https://docs.confluent.io/kafka/introduction.html) broker. [Telegraf](https://docs.influxdata.com/telegraf/v1.26/) is then used to consume the telemetry from Kafka and ingest it into InfluxDB. The entire flow is orchestrated using [Docker Compose](https://docs.docker.com/compose/).



## How?
- `docker compose up`
- Wait for the containers to be up and running and for log messages to confirm that telemetry is being sent.
- Open http://localhost:8086 in the browser and login with the InfluxDB credentials specified in thhe `.env` file.
- In the Influx Query Editor, try the following [Flux query](https://docs.influxdata.com/influxdb/v2.6/query-data/get-started/query-influxdb/) to visualize the raw data.
```flux
from(bucket: "ts-bucket")
|> range(start: -15m)
```



### Configuration
- All credentials are stored in the `.env` file.
- To modify the telemetry payload, the env vars `Template` and `Variables` under the `iot-telemetry-simulator` service in `docker-compose.yml` can be used.
- To configure the [JSON parsing](https://docs.influxdata.com/telegraf/v1.26/data_formats/input/json/) and Influx DB measurements, please modify `telegraf.conf` accordingly. A reference Telegraf config can be generated by executing
```
docker run --rm telegraf telegraf config > default-telegraf.conf
```

## Smoke Test
To validate that the Simulator is working E2E, we can execute the script `smoke-test.sh`.