MQTT to Redis

Description

ezvpn-mqtt-redis listens on an MQTT broker and writes data to a redis database.

In IOhubTM architecture, ezvpn-mqtt-redis will subscribe fld/+/r/# topic to the ezvpn-mqtt broker, and store data read to Redis.

Each measurement is:

  • saved into a Redis sorted hash with key name = <protocol>/<measurement>
  • each entry of the key has value <timestamp>:<value>
  • the timestamp is used as score of each entry

Only topics following the internal format ({ "value": <value>, "ts": <timestamp> }) can be managed by ezvpn-mqtt-redis.

MQTT to redis Schema

How to use it

ezvpn-mqtt-redis is a Docker container image pre-configured for communicate with the ezvpn-mqtt and ezvpn-redis containers. To use it, you will need to install it along with ezvpn-mqtt and ezvpn-redis, and it will be ready to use.

Buffer

You can enable buffer using MQTT_WANT_QOS2 environment variable. Check retry on error variables to configure error handling.

Environment variables

When you start the ezvpn-mqtt-redis container, you can adjust the instance's configuration by passing one or more environment variables to the docker run command.

MQTT Connection

  • MQTT_HOST: MQTT host. Defaults to 127.0.0.1
  • MQTT_PORT: MQTT port. Defaults to 1883
  • MQTT_IN_TOPIC: IOhubTM MQTT topic to subscribe (e.g. fld/modbus/r/#). Defaults to fld/+/r/#. Subscribe to multiple topics can be obtained defining each topic on a separated line.
  • MQTT_WANT_QOS2: ask MQTT to upgrade each incoming message on MQTT_IN_TOPIC to QoS 2 (delivery guaranteed). MQTT will honor the request only if persistence is enabled.

Redis Connection

  • REDIS_HOST: Redis host. Defaults to 127.0.0.1
  • REDIS_PORT: Redis port. Defaults to 6379
  • REDIS_PASSWORD: Redis authorization password.
  • REDIS_EXPIRE: The number of seconds after which each saved value expires. Defaults to 3600 (1h). Max value is 604800 (1 week).

Other variables

  • SKIP_RETAIN: if true, discard all incoming MQTT messages with retain flag set to true. Defaults to false.

Docker container details

Image: us-central1-docker.pkg.dev/ez-shared/iohub/iohub-mqtt-redis

Supported architecture: amd64

Changelog

v1.0.0
  • First Release