{"id":15178872,"url":"https://github.com/cho45/mqtt_topic_exporter","last_synced_at":"2025-10-26T17:31:20.962Z","repository":{"id":61623488,"uuid":"142574951","full_name":"cho45/mqtt_topic_exporter","owner":"cho45","description":"Subscribe MQTT topics and export them to prometheus.","archived":false,"fork":false,"pushed_at":"2018-07-29T01:50:14.000Z","size":10,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T21:52:43.236Z","etag":null,"topics":["dashboard","grafana","iot","metrics","monitoring","mqtt","prometheus","prometheus-exporter"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cho45.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-27T12:33:33.000Z","updated_at":"2023-02-19T04:34:06.000Z","dependencies_parsed_at":"2022-10-18T17:30:17.725Z","dependency_job_id":null,"html_url":"https://github.com/cho45/mqtt_topic_exporter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fmqtt_topic_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fmqtt_topic_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fmqtt_topic_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fmqtt_topic_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cho45","download_url":"https://codeload.github.com/cho45/mqtt_topic_exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375210,"owners_count":19461569,"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":["dashboard","grafana","iot","metrics","monitoring","mqtt","prometheus","prometheus-exporter"],"created_at":"2024-09-27T15:40:55.892Z","updated_at":"2025-10-26T17:31:20.957Z","avatar_url":"https://github.com/cho45.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"mqtt\\_topic\\_exporter\n==================\n\nSubscribe MQTT topic and export them to prometheus.\n\n```\nusage: mqtt_topic_exporter --mqtt.server=MQTT.SERVER --mqtt.topic=MQTT.TOPIC [\u003cflags\u003e]\n\nFlags: \n  -h, --help                     Show context-sensitive help (also try --help-long and --help-man).\n      --web.listen-address=\":9981\"  \n                                 Address on which to expose metrics and web interface.\n      --web.telemetry-path=\"/metrics\"  \n                                 Path under which to expose metrics.\n      --mqtt.retain-time=\"1m\"    Retain duration for a topic\n      --mqtt.server=MQTT.SERVER  MQTT Server address URI mqtts://user:pass@host:port\n      --mqtt.topic=MQTT.TOPIC    Watch MQTT topic\n      --log.level=\"info\"         Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]\n      --log.format=\"logger:stderr\"  \n                                 Set the log target and format. Example: \"logger:syslog?appname=bob\u0026local=7\" or \"logger:stdout?json=true\"\n      --version                  Show application version.\n```\n\nSample output:\n```\ncurl -s http://127.0.0.1:9981/metrics | grep mqtt\n# HELP mqtt_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which mqtt_exporter was built.\n# TYPE mqtt_exporter_build_info gauge\nmqtt_exporter_build_info{branch=\"\",goversion=\"go1.10.3\",revision=\"\",version=\"\"} 1\n# HELP mqtt_topic mqtt topic gauge\n# TYPE mqtt_topic gauge\nmqtt_topic{topic=\"/home/sensor/co2\"} 462\nmqtt_topic{topic=\"/home/sensor/temp\"} 31.171875\n```\n\n## Development with Dev Container\n\nThis repository supports [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers).\n\n### How to start the Dev Container\n1. Open this repository in VS Code.\n2. Open the command palette (`F1` or `Ctrl+Shift+P`) and select `Dev Containers: Reopen in Container`.\n\nThis will automatically build and start the development container environment.\n\n---\n\n## Build Instructions\n\n```sh\nmake build\n```\nOr\n```sh\ngo build -o mqtt_topic_exporter main.go\n```\n\n---\n\n## Debugging and Testing\n\n### 1. Start the MQTT broker\n\n```sh\ndocker-compose up -d mosquitto\n```\n\n### 2. Run the application\n\n```sh\nmake run\n```\nOr\n```sh\n./mqtt_topic_exporter --mqtt.server=mqtt://mosquitto:1883 --mqtt.topic=/test/topic\n```\n\n### 3. Check Prometheus metrics\n\nIn another terminal, run:\n\n```sh\ncurl -s http://localhost:9981/metrics | grep mqtt\n```\n\n---\n\n## Testing MQTT Publish (pubtest)\n\nA sample Go program is included at `cmd/pubtest/main.go` for publishing test messages to the MQTT broker.\n\n### Usage\n\nRun the publisher directly with `go run`:\n```sh\n go run cmd/pubtest/main.go /test/topic 42.5\n```\n\nThis will publish a test message to the MQTT broker at `mqtt://mosquitto:1883`.\n\nYou can modify the command line arguments to change topics, payloads, or broker address as needed.\n\n---\n\n### Notes\n- The MQTT broker configuration file is located at `.devcontainer/mosquitto.conf`.\n- From inside the Dev Container, you can connect to the broker using `mqtt://mosquitto:1883`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fmqtt_topic_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcho45%2Fmqtt_topic_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fmqtt_topic_exporter/lists"}