{"id":26824822,"url":"https://github.com/cybcon/docker.mqtt2elasticsearch","last_synced_at":"2026-04-12T14:40:36.022Z","repository":{"id":204452041,"uuid":"711805470","full_name":"cybcon/docker.mqtt2elasticsearch","owner":"cybcon","description":"Reads json formatted mqtt messages and stores them into an elasticsearch database.","archived":false,"fork":false,"pushed_at":"2025-03-10T18:01:10.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T18:48:11.807Z","etag":null,"topics":["docker-compose","docker-image","elasticsearch-client","json","mosquitto","mqtt-client","python3"],"latest_commit_sha":null,"homepage":"https://www.oberdorf-itc.de/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cybcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.paypal.com/donate/?hosted_button_id=BHGJGGUS6RH44"]}},"created_at":"2023-10-30T08:02:24.000Z","updated_at":"2025-03-10T18:00:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a92bf2b-1a3b-433c-8086-57b8603b0110","html_url":"https://github.com/cybcon/docker.mqtt2elasticsearch","commit_stats":null,"previous_names":["cybcon/docker.mqtt2elasticsearch"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybcon%2Fdocker.mqtt2elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybcon%2Fdocker.mqtt2elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybcon%2Fdocker.mqtt2elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybcon%2Fdocker.mqtt2elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cybcon","download_url":"https://codeload.github.com/cybcon/docker.mqtt2elasticsearch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301992,"owners_count":20755514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","docker-image","elasticsearch-client","json","mosquitto","mqtt-client","python3"],"created_at":"2025-03-30T10:17:42.489Z","updated_at":"2026-04-12T14:40:36.010Z","avatar_url":"https://github.com/cybcon.png","language":"Python","funding_links":["https://www.paypal.com/donate/?hosted_button_id=BHGJGGUS6RH44"],"categories":[],"sub_categories":[],"readme":"# Quick reference\n\nMaintained by: [Michael Oberdorf IT-Consulting](https://www.oberdorf-itc.de/)\n\nSource code: [GitHub](https://github.com/cybcon/docker.mqtt2elasticsearch)\n\nContainer image: [DockerHub](https://hub.docker.com/repository/docker/oitc/mqtt2elasticsearch)\n\n\u003c!-- SHIELD GROUP --\u003e\n[![][github-action-test-shield]][github-action-test-link]\n[![][github-action-release-shield]][github-action-release-link]\n[![][github-release-shield]][github-release-link]\n[![][github-releasedate-shield]][github-releasedate-link]\n[![][github-stars-shield]][github-stars-link]\n[![][github-forks-shield]][github-forks-link]\n[![][github-issues-shield]][github-issues-link]\n[![][github-license-shield]][github-license-link]\n\n[![][docker-release-shield]][docker-release-link]\n[![][docker-pulls-shield]][docker-pulls-link]\n[![][docker-stars-shield]][docker-stars-link]\n[![][docker-size-shield]][docker-size-link]\n\n# Supported tags and respective `Dockerfile` links\n\n* [`latest`, `1.3.0`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.3.0/Dockerfile)\n* [`1.2.2`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.2.2/Dockerfile)\n* [`1.2.1`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.2.1/Dockerfile)\n* [`1.1.1`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.1.1/Dockerfile)\n* [`1.1.0`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.1.0/Dockerfile)\n* [`1.0.0`](https://github.com/cybcon/docker.mqtt2elasticsearch/blob/v1.0.0/Dockerfile)\n\n# Summary\n\nThe container image is based on Alpine Linux with python3 interpreter.\nThe tool is written in python and connects to a MQTT server and subscripes to one ore more topics.\nAll messages in that topic will be pushed to an elasticsearch or opensearch server.\n\n# Prerequisites to run the docker container\n1. You need a MQTT server to read the data from the topics.\n2. You need an elasticsearch v8 / or opensearch v2 database to store the data inside.\n\n# Configuration\n## Container configuration\n\nThe container grab some configuration via environment variables.\n\n| Environment variable name    | Description                                                                                      | Required     | Default value                               |\n|------------------------------|--------------------------------------------------------------------------------------------------|--------------|---------------------------------------------|\n| `CONFIG_FILE`                | The general configuration file that contains the connection parameters to MQTT and Elasticsearch | **OPTIONAL** | `/app/etc/mqtt2elasticsearch.json`          |\n| `ELASTICSEARCH_MAPPING_FILE` | The MQTT topics and the associated Elasticsearch index configuration for the messages.           | **OPTIONAL** | `/app/etc/mqtt2elasticsearch-mappings.json` |\n\n\n\n## General configuration file\n\nThe path and filename to the general configuration file can be set via environment variable `CONFIG_FILE`. By default, the script will use `/app/etc/mqtt2elasticsearch.json`.\n\nInside this file we need to configure the Elasticsearch (or Opensearch) and MQTT server connection parameters.\n\n### Example with Elasticsearch\n\n```json\n{\n\"DEBUG\": true,\n\"removeIndex\": false,\n\"elasticsearch\": {\n  \"cluster\": [ \"http://elasticsearch:9200/\" ]\n  },\n\"mqtt\": {\n  \"client_id\": \"mqtt2elasticsearch\",\n  \"user\": \"mqtt2elasticsearch\",\n  \"password\": \"myPassword\",\n  \"server\": \"test.mosquitto.org\",\n  \"port\": 1883,\n  \"tls\": false,\n  \"hostname_validation\": true,\n  \"protocol_version\": 3\n  }\n}\n```\n\n### Example with Opensearch\n\n```json\n{\n\"DEBUG\": true,\n\"removeIndex\": false,\n\"opensearch\": {\n  \"hosts\": [\n    {\n      \"host\": \"opensearch\",\n      \"port\": 9200\n    }\n  ],\n  \"tls\": true,\n  \"verify_certs\": true,\n  \"username\": \"admin\",\n  \"password\": \"admin\"\n  },\n\"mqtt\": {\n  \"client_id\": \"mqtt2elasticsearch\",\n  \"user\": \"mqtt2elasticsearch\",\n  \"password\": \"myPassword\",\n  \"server\": \"test.mosquitto.org\",\n  \"port\": 1883,\n  \"tls\": false,\n  \"hostname_validation\": true,\n  \"protocol_version\": 3\n  }\n}\n```\n\n\n### Field description\n\n| Field                      | Type    | Description                                                                                                      |\n|----------------------------|---------|------------------------------------------------------------------------------------------------------------------|\n| `DEBUG`                    | Boolean | Enable debug output on stdout                                                                                    |\n| `removeIndex`              | Boolean | If this flag is set to `true`, the script will remove the Elasticsearch index and exits.                         |\n| `elasticsearch`            | Object  | Contains Elasticsearch specific configuration parameters.                                                        |\n| `elasticsearch.cluster`    | Array   | Contains a list of Eleasticsearch cluster node URLs.                                                             |\n| `elasticsearch.api_ley`    | String  | Optional api\\_key if Elasticsearch requires authentication.                                                      |\n| `opensearch`               | Object  | Contains Opensearch specific configuration parameters.                                                           |\n| `opensearch.hosts`         | Array   | Contains a list of Opensearch hosts objects.                                                                     |\n| `opensearch.hosts[].host`  | String  | Opensearch hostname (fqdn) or IP address.                                                                        |\n| `opensearch.hosts[].port`  | String  | Optional Opensearch TCP port (Default: 9200).                                                                    |\n| `opensearch.username`      | String  | Optional username for authentication (Default: null).                                                            |\n| `opensearch.password`      | String  | Optional password for authentication (Default: null.                                                             |\n| `opensearch.tls`           | Boolean | Optional if a TLS encrpted communication should be established or not (Default: false).                          |\n| `opensearch.verify_certs`  | Boolean | Optional to validate the server certificate ort not (Default: false).                                            |\n| `opensearch.ca_certs_path` | String  | Optional path to CA certs (Default: \"/etc/ssl/certs/ca-certificates.crt\").                                       |\n| `mqtt`                     | Object  | Contains MQTT specific configuration parameters.                                                                 |\n| `mqtt.client_id`           | String  | The MQTT client identifier.                                                                                      |\n| `mqtt.user`                | String  | The username to authenticate to the MQTT server.                                                                 |\n| `mqtt.password`            | String  | The password to authenticate to the MQTT server.                                                                 |\n| `mqtt.server`              | String  | IP address or FQDN of the MQTT server.                                                                           |\n| `mqtt.port`                | String  | The TCP port number of the MQTT server.                                                                          |\n| `mqtt.tls`                 | Boolean | If a TLS encrpted communication should be established or not.                                                    |\n| `mqtt.hostname_validation` | Boolean | Validate the hostname from the servercertificate or not.                                                         |\n| `mqtt.protocol_version`    | Integer | The MQTT protocol version. Can be 3 (for MQTTv311) or 5 (for MQTTv5).                                            |\n\n\n##  Elasticsearch/Opensearch index configuration file\n\nThe path and filename to the Elasticsearch/Opensearch index configuration file can be set via environment variable `ELASTICSEARCH_MAPPING_FILE`.\nBy default, the script will use `/app/etc/mqtt2elasticsearch-mappings.json`.\n\nInside this file we need to configure the MQTT topic and the associated Elasticsearch/Opensearch index with it's configuration.\n\n### Example\n\nThis is  minimal example. The JSON file contains the MQTT topic as **key**. Every topic contains the associated Elasticsearch/Opensearch index and an optional index configuration.\nYou can use placeholder inside the index name. Following will be translated on the fly:\n- `{Y}`: the 4-digit year\n- `{m}`: the 2-digit month\n- `{d}`: the 2-digit day\n\n```json\n{\n  \"de/oberdorf-itc/some/topic\": {\n    \"elasticIndex\": \"mydata-{Y}-{m}\",\n    \"elasticBody\": {\n    }\n  }\n}\n```\n\nFull blown examples can be found here:\n- [speedtest2mqtt-elasticsearch-mapping.json](./examples/speedtest2mqtt-elasticsearch-mapping.json).\n- [dockerhub-stats-opensearch-mapping.json](./examples/dockerhub-stats-opensearch-mapping.json).\n\n\n### Field description\n\n| Field                      | Type   | Description |\n|----------------------------|--------|-------------|\n| *\\\u003ctopic\\\u003e*                | String | The MQTT topic to subscripe to                                                                                                                                    |\n| *\\\u003ctopic\\\u003e*.`elasticIndex` | String | The name of the Elasticsearch index. Allowed placeholders are `{Y}` (year), `{m}` (month) and `{d}` (day)                                                         |\n| *\\\u003ctopic\\\u003e*.`elasticBody`  | Object | The Elastic index configuration as documented here: [Create index API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html) |\n\n\n# Running the container image\n\n```\ndocker run --rm oitc/mqtt2elasticsearch:latest\n```\n\n# Docker compose configuration\n\n```yaml\nversion: '3.8'\n\nservices:\n  elasticsearch:\n    restart: always\n    image: elasticsearch:8.10.2\n    container_name: elasticsearch\n    hostname: elasticsearch\n    environment:\n      - cluster.name=docker-cluster\n      - discovery.type=single-node\n      - bootstrap.memory_lock=true\n      - \"ES_JAVA_OPTS=-Xms512m -Xmx512m\"\n      - xpack.security.enabled=false\n      - xpack.security.enrollment.enabled=false\n    ulimits:\n      memlock:\n        soft: -1\n        hard: -1\n    ports:\n      - 9200:9200\n    volumes:\n      - /srv/docker/elasticsearch/data:/usr/share/elasticsearch/data\n    healthcheck:\n      test: [\"CMD\", \"wget\", \"http://localhost:9200\", \"-O-\"]\n      interval: 1s\n      timeout: 1s\n      retries: 120\n\n  kibana:\n    restart: always\n    image: kibana:8.10.2\n    container_name: kibana\n    hostname: kibana\n    ports:\n      - 5601:5601\n    volumes:\n      - /srv/docker/kibana/etc:/usr/share/kibana/config\n    depends_on:\n      - elasticsearch\n\n  mqtt2elasticsearch:\n    restart: always\n    image: oitc/mqtt2elasticsearch\n    container_name: mqtt2elasticsearch\n    hostname: mqtt2elasticsearch\n    volumes:\n      - /srv/docker/mqtt2elasticsearch/etc/speedtest2mqtt-elasticsearch-mapping.json:/app/etc/mqtt2elasticsearch-mappings.json:ro\n    depends_on:\n      - elasticsearch\n\n  speedtest2mqtt:\n    container_name: speedtest2mqtt\n    restart: always\n    read_only: true\n    user: 2536:2536\n    image: oitc/speedtest2mqtt\n    environment:\n      MQTT_SERVER: test.mosquitto.org\n      MQTT_PORT: 1883\n      MQTT_TOPIC: de/oberdorf-itc/speedtest2mqtt/results\n      FREQUENCE: 300\n    secrets:\n      - speedtest2mqtt_mqtt_password\n    tmpfs:\n      - /tmp\n\nsecrets:\n  speedtest2mqtt_mqtt_password:\n    file: /srv/docker/speedtest2mqtt/secrets/mqtt_password\n```\n\n# Donate\nI would appreciate a small donation to support the further development of my open source projects.\n\n\u003ca href=\"https://www.paypal.com/donate/?hosted_button_id=BHGJGGUS6RH44\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png\" alt=\"Donate with PayPal\" width=\"200px\"\u003e\u003c/a\u003e\n\n\n# License\n\nCopyright (c) 2023-2026 Michael Oberdorf IT-Consulting\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\u003c!-- LINK GROUP --\u003e\n[docker-pulls-link]: https://hub.docker.com/r/oitc/mqtt2elasticsearch\n[docker-pulls-shield]: https://img.shields.io/docker/pulls/oitc/mqtt2elasticsearch?color=45cc11\u0026labelColor=black\u0026style=flat-square\n[docker-release-link]: https://hub.docker.com/r/oitc/mqtt2elasticsearch\n[docker-release-shield]: https://img.shields.io/docker/v/oitc/mqtt2elasticsearch?color=369eff\u0026label=docker\u0026labelColor=black\u0026logo=docker\u0026logoColor=white\u0026style=flat-square\n[docker-size-link]: https://hub.docker.com/r/oitc/mqtt2elasticsearch\n[docker-size-shield]: https://img.shields.io/docker/image-size/oitc/mqtt2elasticsearch?color=369eff\u0026labelColor=black\u0026style=flat-square\n[docker-stars-link]: https://hub.docker.com/r/oitc/mqtt2elasticsearch\n[docker-stars-shield]: https://img.shields.io/docker/stars/oitc/mqtt2elasticsearch?color=45cc11\u0026labelColor=black\u0026style=flat-square\n[github-action-release-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/actions/workflows/release-from-label.yaml\n[github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/cybcon/docker.mqtt2elasticsearch/release-from-label.yaml?label=release\u0026labelColor=black\u0026logo=githubactions\u0026logoColor=white\u0026style=flat-square\n[github-action-test-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/actions/workflows/container-image-build-validation.yaml\n[github-action-test-shield-original]: https://github.com/cybcon/docker.mqtt2elasticsearch/actions/workflows/container-image-build-validation.yaml/badge.svg\n[github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/cybcon/docker.mqtt2elasticsearch/container-image-build-validation.yaml?label=tests\u0026labelColor=black\u0026logo=githubactions\u0026logoColor=white\u0026style=flat-square\n[github-forks-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/network/members\n[github-forks-shield]: https://img.shields.io/github/forks/cybcon/docker.mqtt2elasticsearch?color=8ae8ff\u0026labelColor=black\u0026style=flat-square\n[github-issues-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/issues\n[github-issues-shield]: https://img.shields.io/github/issues/cybcon/docker.mqtt2elasticsearch?color=ff80eb\u0026labelColor=black\u0026style=flat-square\n[github-license-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/blob/main/LICENSE\n[github-license-shield]: https://img.shields.io/badge/license-MIT-blue?labelColor=black\u0026style=flat-square\n[github-release-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/releases\n[github-release-shield]: https://img.shields.io/github/v/release/cybcon/docker.mqtt2elasticsearch?color=369eff\u0026labelColor=black\u0026logo=github\u0026style=flat-square\n[github-releasedate-link]: https://github.com/cybcon/docker.mqtt2elasticsearch/releases\n[github-releasedate-shield]: https://img.shields.io/github/release-date/cybcon/docker.mqtt2elasticsearch?labelColor=black\u0026style=flat-square\n[github-stars-link]: https://github.com/cybcon/docker.mqtt2elasticsearch\n[github-stars-shield]: https://img.shields.io/github/stars/cybcon/docker.mqtt2elasticsearch?color=ffcb47\u0026labelColor=black\u0026style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybcon%2Fdocker.mqtt2elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcybcon%2Fdocker.mqtt2elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybcon%2Fdocker.mqtt2elasticsearch/lists"}