When investigating why there are gaps in the temperature/CO2 graphs for certain devices, I arrived at the metrics not being presented by the Prometheus MQTT exporter contiguously. When querying the Prometheus HTTP endpoint of the MQTT exporter, given metric is present in one response, only to be gone in the next response, even though based on watching the topic confirms that the metric is published frequently, like every couple of seconds. For example, checking the metrics sent to the devices/pracovna/qtpy topic multiple times, I see this on two back-to-back curl invocations:
The second line of the output got changed to different topic/metric but sharing the sensor value.
The pattern to extract the device ID in the configuration was "(.*/)?(?P<deviceid>.*)".
What seems to be happening is that the temperature metric is aggregated to the sensor key and given the last component of the topic is the same (qtpy, based on device type), the metric is switched based on the last received MQTT message that maps to the sensor key.
When investigating why there are gaps in the temperature/CO2 graphs for certain devices, I arrived at the metrics not being presented by the Prometheus MQTT exporter contiguously. When querying the Prometheus HTTP endpoint of the MQTT exporter, given metric is present in one response, only to be gone in the next response, even though based on watching the topic confirms that the metric is published frequently, like every couple of seconds. For example, checking the metrics sent to the
devices/pracovna/qtpy
topic multiple times, I see this on two back-to-backcurl
invocations:The second line of the output got changed to different topic/metric but sharing the
sensor
value.The pattern to extract the device ID in the configuration was
"(.*/)?(?P<deviceid>.*)"
.What seems to be happening is that the temperature metric is aggregated to the
sensor
key and given the last component of the topic is the same (qtpy
, based on device type), the metric is switched based on the last received MQTT message that maps to the sensor key.The device ID needs to be made unique.