kpetremann / mqtt-exporter

Simple generic MQTT Prometheus exporter for IoT working out of the box
https://hub.docker.com/r/kpetrem/mqtt-exporter
MIT License
111 stars 30 forks source link

Timeout on value #86

Closed zoic21 closed 1 hour ago

zoic21 commented 3 weeks ago

Hello

Thanks for the exporter it’s very usefull !!!!! CAN you add a timeout on value, for exemple I send temperture on mqtt each minute but if I stop the send mqtt exporter continue to expose my sensor temperature.

What I want it’s a paramètre to define lifetime of value. With that it’s will be mark as no data in grafana and I can get an alert.

Thanks in advance.

bo0tzz commented 3 weeks ago

This could also be an alternative resolution to #68

kpetremann commented 2 weeks ago

hello @zoic21,

I am glad it useful to you :) Looking into it.

hello @bo0tzz, got it.

kpetremann commented 1 week ago

what about having a timestamp metric associated to the metric:

mqtt_temperature{sensor="zigbee2mqtt_kitchen"} 19.32
mqtt_temperature_ts{sensor="zigbee2mqtt_kitchen"} 1.731969306e+09

The second metric is updated only when receiving a new message in MQTT for this metric.

Code is in this branch for now: https://github.com/kpetremann/mqtt-exporter/tree/timestamp

If it is ok for you, I'll add an option to enable (disabled by default because it doubles the number of metrics).

kpetremann commented 2 days ago

@zoic21 @bo0tzz does PR #87 work for you?

bo0tzz commented 2 days ago

It feels a bit hacky (not your fault) but should do the job I think

zoic21 commented 1 day ago

Hello Sorry for delay, yes I can used that just and manage alert with this timestamp

kpetremann commented 1 hour ago

Closing this issue: PR merged, the new feature is available in the latest version. Feel free to reopen the issue if needed. Cheers