{"id":24986882,"url":"https://github.com/jesseklm/prom2mqtt","last_synced_at":"2026-05-13T07:03:17.604Z","repository":{"id":275625749,"uuid":"926668454","full_name":"jesseklm/prom2mqtt","owner":"jesseklm","description":"Bridge Prometheus metrics to MQTT for IoT and smart home integration. Configure scrapers, filter metrics, and publish to MQTT brokers with ease.","archived":false,"fork":false,"pushed_at":"2025-02-13T22:26:40.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T23:28:52.288Z","etag":null,"topics":["home-assistant","iot","metrics","monitoring","mqtt","mqtt-bridge","prometheus","prometheus-exporter","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jesseklm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-02-03T16:57:40.000Z","updated_at":"2025-02-13T22:26:43.000Z","dependencies_parsed_at":"2025-02-03T18:24:55.294Z","dependency_job_id":null,"html_url":"https://github.com/jesseklm/prom2mqtt","commit_stats":null,"previous_names":["jesseklm/prom2mqtt"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesseklm%2Fprom2mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesseklm%2Fprom2mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesseklm%2Fprom2mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesseklm%2Fprom2mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jesseklm","download_url":"https://codeload.github.com/jesseklm/prom2mqtt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174539,"owners_count":20735413,"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":["home-assistant","iot","metrics","monitoring","mqtt","mqtt-bridge","prometheus","prometheus-exporter","python"],"created_at":"2025-02-04T11:33:05.344Z","updated_at":"2026-05-13T07:03:17.535Z","avatar_url":"https://github.com/jesseklm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prom2MQTT\n\nA lightweight Python bridge to scrape Prometheus metrics and publish them to an MQTT broker. Designed for IoT use cases, smart home systems (e.g., Home Assistant), and monitoring pipelines.\n\n## Overview\n\nProm2MQTT periodically fetches metrics from configured Prometheus exporters, applies flexible label-based filters, and publishes the metrics to an MQTT broker. The metrics are converted into MQTT topics for straightforward integration with IoT platforms, dashboards, or automation systems.\n\n## Features\n\n- **Scrape Prometheus endpoints** on a configurable interval\n- **Label-based filtering** to publish only specific metrics\n- **Async I/O** for efficient performance\n- **Customizable topic structure** using metric names and labels\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/jesseklm/prom2mqtt.git\ncd prom2mqtt\n```\n\n2. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Configuration\n\nCreate a `config.yaml` file:\n\n```yaml\nmqtt_server: \"mqtt://localhost:1883\"\nmqtt_topic: \"home/metrics/\"\nmqtt_username: \"user\"\nmqtt_password: \"pass\"\nupdate_rate: 60  # Seconds between updates\n\nscrapers:\n  - exporter_url: \"http://localhost:9100/metrics\"\n    filters:\n      node_cpu_seconds_total:\n        cpu:\n          - \"0\"\n          - \"1\"\n        mode: idle\n      node_memory_Active_bytes:\n```\n\n- **mqtt_server**: The MQTT broker URL. For TLS, you could use `mqtts://your-broker:8883`.\n- **mqtt_topic**: The base MQTT topic for published metrics (e.g., `home/metrics/node_cpu_seconds_total_cpu_0_mode_idle`).\n- **update_rate**: Interval in seconds between scrapes.\n- **scrapers**: A list of Prometheus endpoints to scrape along with filters:\n  - In this example, `node_cpu_seconds_total` is published only for `cpu` values `\"0\"` or `\"1\"` and `mode=\"idle\"`.  \n  - `node_memory_Active_bytes` is published with no additional label filters.\n\n## Usage\n\nRun the service:\n```bash\npython prom2mqtt.py\n```\n\n### Example MQTT Topic\n\nA metric like:\n```\nnode_cpu_seconds_total{cpu=\"0\",mode=\"idle\"}\n```\nis published to the MQTT topic:\n```\nhome/metrics/node_cpu_seconds_total_cpu_0_mode_idle\n```\n\n## Metrics Filtering\n\nOnly metrics (and their labels) listed under `filters` in `config.yaml` are published.  \nUse the exact Prometheus metric names (e.g., `node_network_up`).  \nFor each label, you can specify either a single value or a list of values to allow.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesseklm%2Fprom2mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjesseklm%2Fprom2mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesseklm%2Fprom2mqtt/lists"}