geerlingguy / airgradient-prometheus

AirGradient Prometheus exporter.
MIT License
174 stars 59 forks source link

Stop sending valid data if sensor stops transmitting #2

Closed geerlingguy closed 2 years ago

geerlingguy commented 3 years ago

One thing I just noticed after I moved one of my sensors (and it stopped connecting to WiFi for some reason): if the sensor goes offline for any reason, and stops sending data to this exporter, the exporter will happily keep reporting the same value from the last reading indefinitely.

That is not the correct behavior for an error condition—what should happen, maybe, is any time Prometheus hits the metrics endpoint, there's a check for the last modification time on the stat file.

If the modification time is older than, say, 5 minutes, then send a 500 error or something along those lines, instead of sending valid (but incorrect) data.

geerlingguy commented 3 years ago

This would be obviated by #4. Which is an awesome little PR.

geerlingguy commented 2 years ago

And it was.