oitc/json2mqtt

By oitc

Updated 17 days ago

Get a HTTP json endpoint and send the json payload to a MQTT topic.

Image
Message queues
Internet of things
Developer tools
0

602

oitc/json2mqtt repository overview

Quick reference

Maintained by: Michael Oberdorf IT-Consulting

Source code: GitHub

Container image: DockerHub

Summary

The container image is based on Alpine Linux and sends a curl request result with the mosquitto-client to a MQTT server topic.

This is the generic version of the other tools:

Prerequisites to run the docker container

You need an MQTT server to send the data to it.

Configuration

Container configuration

The container grab the configuration via environment variables.

Environment variable nameDescriptionRequiredDefault value
MQTT_SERVERThe MQTT server hostname or IP addressOPTIONALlocalhost
MQTT_PORTThe TCP port of the MQTT serverOPTIONAL1883
MQTT_TLS_enabledShould SSL communication be enabled (true) or not (false)OPTIONALfalse
MQTT_CACERT_FILEIf TLS is enabled, the path to the CA certificate file to validate the MQTT server certificateOPTIONAL
MQTT_TLS_no_hostname_validationIf TLS is enabled, skip the hostname validation of the TLS certificateOPTIONALfalse
MQTT_USERThe MQTT username for MQTT authenticationOPTIONAL
MQTT_PASSWORDThe MQTT password for MQTT authenticationOPTIONAL
MQTT_PASSWORD_FILEThe filepath where the MQTT password is stored for MQTT authenticationOPTIONAL
MQTT_TOPICThe MQTT topic to send the Github statistics toMANDATORY
MQTT_RETAINSet the retain flag when publishing the Github statistics to MQTT topicOPTIONALfalse
ENDPOINTThe http(s) endpoint from where to get the jsonMANDATORY
ADD_TIMESTAMPAdd a timestamp field to the 1st level of the json object.OPTIONALtrue
TIMESTAMP_ATTRThe timestamp field attribute name to add the timestamp.OPTIONALtimestamp

Docker compose configuration

services:
  json2mqtt:
    restart: "no"
    user: 3851:3851
    image: oitc/json2mqtt:latest
    environment:
      MQTT_SERVER: test.mosquitto.org
      MQTT_PORT: 1883
      MQTT_TOPIC: com/github/repositories/metrics
      ENDPOINT: https://naas.isalman.dev/no

A bigger example can be found here: docker-compose.yaml

Donate

I would appreciate a small donation to support the further development of my open source projects.

Donate with PayPal

License

Copyright (c) 2026 Michael Oberdorf IT-Consulting

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tag summary

Content type

Image

Digest

sha256:3c1e6acf0

Size

7.5 MB

Last updated

17 days ago

docker pull oitc/json2mqtt