{"id":15980782,"url":"https://github.com/macbre/airrohr-prometheus-exporter","last_synced_at":"2025-05-07T06:22:10.197Z","repository":{"id":37863216,"uuid":"290012833","full_name":"macbre/airrohr-prometheus-exporter","owner":"macbre","description":"Make prometheus collect temperature, pressure and PM metrics from your airrohr station","archived":false,"fork":false,"pushed_at":"2025-01-29T10:28:57.000Z","size":263,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T22:21:47.107Z","etag":null,"topics":["airrohr","environmental-monitoring","luftdaten","monitoring-station","pm25","prometheus-exporter","temperature-monitoring"],"latest_commit_sha":null,"homepage":"","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/macbre.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":"2020-08-24T18:52:19.000Z","updated_at":"2025-01-29T10:29:01.000Z","dependencies_parsed_at":"2023-10-02T12:40:19.845Z","dependency_job_id":"9c28417d-b22d-4d8b-b038-dd8cffc24cc1","html_url":"https://github.com/macbre/airrohr-prometheus-exporter","commit_stats":{"total_commits":259,"total_committers":2,"mean_commits":129.5,"dds":0.2625482625482626,"last_synced_commit":"93aba3d49a412f49252023ef1976848bb363460c"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Fairrohr-prometheus-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Fairrohr-prometheus-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Fairrohr-prometheus-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Fairrohr-prometheus-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macbre","download_url":"https://codeload.github.com/macbre/airrohr-prometheus-exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242921546,"owners_count":20207064,"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":["airrohr","environmental-monitoring","luftdaten","monitoring-station","pm25","prometheus-exporter","temperature-monitoring"],"created_at":"2024-10-08T00:22:36.786Z","updated_at":"2025-03-10T20:31:47.777Z","avatar_url":"https://github.com/macbre.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# airrohr-prometheus-exporter\nThis a HTTP server that accepts data sent by [`airrohr` AirQuality monitoring station](https://sensor.community/en/sensors/airrohr/) (temperature, pressure and PM metrics) and exposes them to [Prometheus](https://prometheus.io/)' metrics collector.\n\nYou can then plot them with [Grafana](https://grafana.com/) and have Prometheus alerting you on the measurements. Observability!\n\n\u003cimg width=\"889\" alt=\"Screenshot 2023-11-21 at 11 03 10\" src=\"https://github.com/macbre/airrohr-prometheus-exporter/assets/1929317/8496cf0f-b35b-4960-959b-700d23cf4b20\"\u003e\n\n## Run using Docker\n\nUp to date container image can be fetched from [GitHub's Container Registry](https://github.com/macbre/airrohr-prometheus-exporter/pkgs/container/airrohr-prometheus-exporter) and run via:\n\n```\ndocker run --detach --restart unless-stopped -p 55123:8888 --name airrohr -t ghcr.io/macbre/airrohr-prometheus-exporter:latest\n```\n\nAnd then:\n\n```\n$ curl 0:55123/metrics\n# HELP airrohr_info Information about the sensor.\n# TYPE airrohr_info gauge\n# HELP airrohr_last_measurement_timestamp When was the most recent data received.\n# TYPE airrohr_last_measurement_timestamp gauge\n```\n\n## Set up your Airrohr sensors\n\n1. Visit the `/config` page of your sensor.\n2. Enable the \"Send data to custom API\" option.\n3. Provide the hostname and the port where your `airrohr-prometheus-exporter` instance is running. Keep `/data.php` as the path.\n\nFor instance:\n\n\u003cimg width=\"618\" alt=\"Screenshot 2023-11-21 at 11 06 17\" src=\"https://github.com/macbre/airrohr-prometheus-exporter/assets/1929317/de0291f9-6fb4-4377-8208-55c935a0309a\"\u003e\n\n## HTTP endpoints\n\n#### `POST /data.php`\n\n[Set up your airrohr station](https://sensor.community/en/sensors/dnms#Configure_the_station) to \"Send data to custom API\" and provide the IP address and port where `airrohr-prometheus-exporter` runs.\n\n#### Example request\n\n```yaml\nPOST /data.php HTTP/1.1\nHost: my.host.name:1234\nUser-Agent: NRZ-2020-129/12331981\nConnection: close\nAccept-Encoding: identity;q=1,chunked;q=0.1,*;q=0\nAuthorization: Basic xxx\nContent-Type: application/json\nX-Sensor: esp8266-12331981\nContent-Length: 481\n\n{\"esp8266id\": \"12331981\", \"software_version\": \"NRZ-2020-129\", \"sensordatavalues\":[{\"value_type\":\"SDS_P1\",\"value\":\"0.40\"},{\"value_type\":\"SDS_P2\",\"value\":\"0.20\"},{\"value_type\":\"BME280_temperature\",\"value\":\"20.47\"},{\"value_type\":\"BME280_pressure\",\"value\":\"100613.25\"},{\"value_type\":\"BME280_humidity\",\"value\":\"69.02\"},{\"value_type\":\"samples\",\"value\":\"4222662\"},{\"value_type\":\"min_micro\",\"value\":\"32\"},{\"value_type\":\"max_micro\",\"value\":\"3301275\"},{\"value_type\":\"signal\",\"value\":\"-94\"}]}\n```\n\nOr from debug logs (via airrohr sensor web UI):\n\n```yaml\n## Sending as csv: \nCSV Output: {\"software_version\": \"NRZ-2024-136-B1\", \"sensordatavalues\":[{\"value_type\":\"temperature\",\"value\":\"35.20\"},{\"value_type\":\"humidity\",\"value\":\"45.30\"},{\"value_type\":\"samples\",\"value\":\"1133404\"},{\"value_type\":\"min_micro\",\"value\":\"25\"},{\"value_type\":\"max_micro\",\"value\":\"99760\"},{\"value_type\":\"interval\",\"value\":\"30000\"},{\"value_type\":\"signal\",\"value\":\"-65\"}]}\n```\n\n#### `GET /metrics`\n\nExposes metrics collected from airrohr stations in Prometheus format.\n\n##### An example\n\n```\n# HELP airrohr_info Information about the sensor.\n# TYPE airrohr_info gauge\nairrohr_info{sensor_id=\"esp8266-12331981\",software=\"NRZ-2020-129\"} 1.0\nairrohr_info{sensor_id=\"esp8266-12326597\",software=\"NRZ-2020-129\"} 1.0\n# HELP airrohr_last_measurement_timestamp When was the most recent data received.\n# TYPE airrohr_last_measurement_timestamp gauge\nairrohr_last_measurement{sensor_id=\"esp8266-12331981\"} 1.598988915e+09\nairrohr_last_measurement{sensor_id=\"esp8266-12326597\"} 1.598988842e+09\n# HELP airrohr_bme280_humidity bme280_humidity metric from airrohr.\n# TYPE airrohr_bme280_humidity gauge\nairrohr_bme280_humidity{sensor_id=\"esp8266-12331981\"} 67.89 1598988915000\nairrohr_bme280_humidity{sensor_id=\"esp8266-12326597\"} 56.13 1598988842000\n...\n```\n\n#### `GET /metrics.json`\n\nExposes metrics collected from airrohr stations in JSON format.\n\n##### An example\n\n```json\n{\n  \"sensors\": [\n    {\n      \"last_read\": 1598988915,\n      \"meta\": {\n        \"software_version\": \"NRZ-2020-129\"\n      },\n      \"metrics\": {\n        \"bme280_humidity\": \"67.89\",\n        \"bme280_pressure\": \"101114.53\",\n        \"bme280_temperature\": \"19.07\",\n        \"max_micro\": \"20783\",\n        \"min_micro\": \"27\",\n        \"samples\": \"4195163\",\n        \"sds_p1\": \"0.30\",\n        \"sds_p2\": \"0.10\",\n        \"signal\": \"-93\"\n      },\n      \"sensor_id\": \"esp8266-12331981\"\n    },\n    {\n      \"last_read\": 1598988842,\n      \"meta\": {\n        \"software_version\": \"NRZ-2020-129\"\n      },\n      \"metrics\": {\n        \"bme280_humidity\": \"56.13\",\n        \"bme280_pressure\": \"101068.25\",\n        \"bme280_temperature\": \"20.91\",\n        \"max_micro\": \"2809\",\n        \"min_micro\": \"32\",\n        \"samples\": \"4387819\",\n        \"signal\": \"-25\"\n      },\n      \"sensor_id\": \"esp8266-12326597\"\n    }\n  ]\n}\n```\n\n## Prometheus\n\nAnd an entry to `scrape_configs` section in your `prometheus.yml` in order to scrape metrics from this exporter:\n\n```yaml\nscrape_configs:\n  - job_name: 'airrohr'\n    static_configs:\n    - targets:\n      # /metrics path is automatically added by Prometheus when scraping metrics\n      # please adjust the port below\n      - your.server.address:55123\n```\n\n\n## Local development\n\nStart this server locally and make a request using `curl`:\n\n```\nFLASK_ENV=devel HTTP_PORT=55123 python app.py\ncurl 0:55123/data.php -H 'X-Sensor: foo' -H 'Content-Type: application/json' -d '{\"esp8266id\": \"12331981\", \"software_version\": \"NRZ-2020-129\", \"sensordatavalues\":[{\"value_type\":\"SDS_P1\",\"value\":\"0.40\"},{\"value_type\":\"SDS_P2\",\"value\":\"0.20\"},{\"value_type\":\"BME280_temperature\",\"value\":\"20.47\"},{\"value_type\":\"BME280_pressure\",\"value\":\"100613.25\"},{\"value_type\":\"BME280_humidity\",\"value\":\"69.02\"},{\"value_type\":\"samples\",\"value\":\"4222662\"},{\"value_type\":\"min_micro\",\"value\":\"32\"},{\"value_type\":\"max_micro\",\"value\":\"3301275\"},{\"value_type\":\"signal\",\"value\":\"-94\"}]}'\n```\n\n### Docker container\n\n```\ndocker pull ghcr.io/macbre/airrohr-prometheus-exporter:latest\ndocker run --detach --restart unless-stopped -p 55123:8888 --name airrohr -t ghcr.io/macbre/airrohr-prometheus-exporter\n```\n\nOr build it from the source code:\n\n```\ndocker build -t airrohr .\ndocker run --detach --restart unless-stopped -p 55123:8888 --name airrohr -t airrohr\n```\n\n## Links\n\n* [airRohr Sensor Firmware for SPS30, SDS011, DHT22, BMP180, BMP/E 280 and many more](https://github.com/opendata-stuttgart/sensors-software/blob/master/airrohr-firmware/Readme.md)\n* [airRohr source code](https://github.com/opendata-stuttgart/sensors-software)\n* [airRohr firmware flashing tool](http://firmware.sensor.community/airrohr/flashing-tool/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacbre%2Fairrohr-prometheus-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacbre%2Fairrohr-prometheus-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacbre%2Fairrohr-prometheus-exporter/lists"}