Skip to content
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

Add Prometheus publisher #640

Open
barcar opened this issue Jul 19, 2023 · 3 comments
Open

Add Prometheus publisher #640

barcar opened this issue Jul 19, 2023 · 3 comments
Labels
enhancement Enhancement of the code, not introducing new features. help-wanted Needs a helping hang or expertise in order to resolve

Comments

@barcar
Copy link

barcar commented Jul 19, 2023

Is your feature request related to a problem? Please describe.

I'm trying to consume more of my metric data into Prometheus (https://prometheus.io) which seems a bit simpler for a novice that InfluxDB. To simplify my metric flow I've been trying to get metrics from source to Prometheus with the fewest number of hops - a bunch of services (esphome, homebridge, ruuvitag) have simple Prometheus exporters.

I found a Prometheus exporter for Ecowitt (https://github.com/JosephRPalmer/ecowitt-bridge) which would allow me to eliminate MQTT for these metrics but it doesn't have the excellent unit conversion and calculated metric capabilities of Ecowitt2MQTT.

Describe the solution you'd like

Ideally I would like the option in Ecowitt2MQTT to enable an additional Prometheus exporter target which would list all the metrics published to MQTT. This endpoint would listen on an alternate port and the metrics would be updated on each refresh from the weather station.

The config would be simply which port to publish the exporter metrics on.

Additional context

This is a sample of the exporter output from the ecowitt-bridge project:

# TYPE ecowitt_baromabshpa gauge
ecowitt_baromabshpa 1007.8364654999999
# HELP ecowitt_tempc ECOWITT data gauge
# TYPE ecowitt_tempc gauge
ecowitt_tempc 17.800000000000004
# HELP ecowitt_humidity ECOWITT data gauge
# TYPE ecowitt_humidity gauge
ecowitt_humidity 80.0
# HELP ecowitt_winddir ECOWITT data gauge
# TYPE ecowitt_winddir gauge
ecowitt_winddir 290.0
# HELP ecowitt_windspeedmph ECOWITT data gauge
# TYPE ecowitt_windspeedmph gauge
ecowitt_windspeedmph 1.12
# HELP ecowitt_windgustmph ECOWITT data gauge
# TYPE ecowitt_windgustmph gauge
etc

It uses the Python prometheus_client (https://github.com/prometheus/client_python) library and simply builds a dictionary of gauges (one per metric) which is updated when a new metric is received (https://github.com/JosephRPalmer/ecowitt-bridge/blob/main/app/app.py).

The prometheus client is configured to listen on an HTTP port and automatically generates the required format output from the gauge dictionary. I'm thinking the MQTT topic could easily be converted to gauge names.

I would be happy to work on a fork to do this myself but my Python is very basic and I'm not sure where best to integrate this functionality. Would the gauge updating be a new publisher? Or would it just slot into the existing MQTT publisher? Would I just hook into the existing server? Or create an additional server instance?

I'll probably start stumbling around in the dark to try and get this to work for myself but whether the result would be a welcome pull request or of sufficient quality for acceptance is hard to say at this stage.

Anyway - just putting the idea out there... thanks for this project. It's great work.

@issuelabeler issuelabeler bot added the python Pull requests that update Python code label Jul 19, 2023
@bachya bachya added enhancement Enhancement of the code, not introducing new features. and removed python Pull requests that update Python code labels Jul 31, 2023
@bachya bachya changed the title Add Prometheus exporter Add Prometheus publisher Aug 21, 2023
@issuelabeler issuelabeler bot added the python Pull requests that update Python code label Aug 21, 2023
@github-actions
Copy link

There hasn't been any activity on this issue recently, so it has been marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment.
This issue will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for some time label Sep 21, 2023
@bachya
Copy link
Owner

bachya commented Sep 21, 2023

Still active.

@bachya bachya added no-stale This issue or PR is exempted from the stale bot and removed stale There has not been activity on this issue or PR for some time labels Sep 21, 2023
@bachya bachya added help-wanted Needs a helping hang or expertise in order to resolve and removed no-stale This issue or PR is exempted from the stale bot python Pull requests that update Python code labels Aug 2, 2024
@bachya
Copy link
Owner

bachya commented Aug 2, 2024

Given that I'm not a Prometheus user and recognizing that my day job is taking 100% of my time these days, it's unlikely that I'll be able to investigate (much less implement this anytime soon). Adding the help-wanted label in case anyone else wants to take a crack at a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features. help-wanted Needs a helping hang or expertise in order to resolve
Projects
None yet
Development

No branches or pull requests

2 participants