Skip to content

Add support for Prometheus/OpenMetrics to One V9 #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

dechamps
Copy link
Contributor

This commit adds a new feature to the One V9 (ONE_I-9PSL) firmware: support for exposing metrics to Prometheus (or any other ingestor compatible with the OpenMetrics format).

With this change, the AirGradient device will make metrics available on the standard HTTP /metrics endpoint, out-of-the-box, with no need to do anything else. All the user has to do is add their device address as a target to their scrape config on their Prometheus server.

For more information on Prometheus and OpenMetrics, see:

This obsoletes projects such as:

It may be a good idea to mention this on the integrations page after this is deployed.

This commit adds a new feature to the One V9 (ONE_I-9PSL) firmware:
support for exposing metrics to Prometheus (or any other ingestor
compatible with the OpenMetrics format).

With this change, the AirGradient device will make metrics available
on the standard HTTP /metrics endpoint, out-of-the-box, with no need to
do anything else. All the user has to do is add their device address as
a target to their scrape config on their Prometheus server.

For more information on Prometheus and OpenMetrics, see:

- https://prometheus.io/docs/instrumenting/exposition_formats/
- https://openmetrics.io/
- https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md

This obsoletes projects such as:

- https://github.com/geerlingguy/airgradient-prometheus/tree/ebfa8d0ac6d8c47649e4642b27e90b98557fb8f7/AirGradient-DIY
- https://forum.airgradient.com/t/prometheus-integration/1504
@dechamps
Copy link
Contributor Author

For reference, here's an example /metrics response from my device with 760f827:

# HELP airgradient_info AirGradient device information
# TYPE airgradient_info info
airgradient_info{airgradient_serial_number="4XXXXXXXXXXc",airgradient_device_type="ONE_I-9PSL",airgradient_library_version="3.0.4"} 1
# HELP airgradient_config_ok 1 if the AirGradient device was able to successfully fetch its configuration from the server
# TYPE airgradient_config_ok gauge
airgradient_config_ok{} 1
# HELP airgradient_post_ok 1 if the AirGradient device was able to successfully send to the server
# TYPE airgradient_post_ok gauge
airgradient_post_ok{} 1
# HELP airgradient_wifi_rssi_dbm WiFi signal strength from the AirGradient device perspective, in dBm
# TYPE airgradient_wifi_rssi_dbm gauge
# UNIT airgradient_wifi_rssi_dbm dbm
airgradient_wifi_rssi_dbm{} -51
# HELP airgradient_co2_ppm Carbon dioxide concentration as measured by the AirGradient S8 sensor, in parts per million
# TYPE airgradient_co2_ppm gauge
# UNIT airgradient_co2_ppm ppm
airgradient_co2_ppm{} 589
# HELP airgradient_pm1_ugm3 PM1.0 concentration as measured by the AirGradient PMS sensor, in micrograms per cubic meter
# TYPE airgradient_pm1_ugm3 gauge
# UNIT airgradient_pm1_ugm3 ugm3
airgradient_pm1_ugm3{} 3
# HELP airgradient_pm2d5_ugm3 PM2.5 concentration as measured by the AirGradient PMS sensor, in micrograms per cubic meter
# TYPE airgradient_pm2d5_ugm3 gauge
# UNIT airgradient_pm2d5_ugm3 ugm3
airgradient_pm2d5_ugm3{} 3
# HELP airgradient_pm10_ugm3 PM10 concentration as measured by the AirGradient PMS sensor, in micrograms per cubic meter
# TYPE airgradient_pm10_ugm3 gauge
# UNIT airgradient_pm10_ugm3 ugm3
airgradient_pm10_ugm3{} 3
# HELP airgradient_pm0d3_p100ml PM0.3 concentration as measured by the AirGradient PMS sensor, in number of particules per 100 milliliters
# TYPE airgradient_pm0d3_p100ml gauge
# UNIT airgradient_pm0d3_p100ml p100ml
airgradient_pm0d3_p100ml{} 594
# HELP airgradient_tvoc_index The processed Total Volatile Organic Compounds (TVOC) index as measured by the AirGradient SGP sensor
# TYPE airgradient_tvoc_index gauge
airgradient_tvoc_index{} 220
# HELP airgradient_tvoc_raw_index The raw input value to the Total Volatile Organic Compounds (TVOC) index as measured by the AirGradient SGP sensor
# TYPE airgradient_tvoc_raw_index gauge
airgradient_tvoc_raw_index{} 30801
# HELP airgradient_nox_index The processed Nitrous Oxide (NOx) index as measured by the AirGradient SGP sensor
# TYPE airgradient_nox_index gauge
airgradient_nox_index{} 1
# HELP airgradient_temperature_degc The ambient temperature as measured by the AirGradient SHT sensor, in degrees Celsius
# TYPE airgradient_temperature_degc gauge
# UNIT airgradient_temperature_degc degc
airgradient_temperature_degc{} 23.69
# HELP airgradient_humidity_percent The relative humidity as measured by the AirGradient SHT sensor
# TYPE airgradient_humidity_percent gauge
# UNIT airgradient_humidity_percent percent
airgradient_humidity_percent{} 39
# EOF

@pnt325 pnt325 merged commit 3e4e2af into airgradienthq:master Feb 29, 2024
austvik added a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants