MQTT data to Grafana

Okay, now it’s clear, and my telegraph is receiving the metrics regularly. The documentation does describe “keep-alive mechanism” but I didn’t understand from whose perspective this is meant—whether it tied to a specific client or it is shared across the server.

It all makes sense now. I mentioned “random periods” here, but after some observation, I realised that Telegraf only received topics when another MQTT client was subscribed and published keep-alive requests. Keep-alive requests are NOT tied to a specific MQTT session or client. The other client could even be a web browser that has opened the dashboard in the VRM portal (even in a remote network). As long as one of these clients periodically publishes keep-alive requests, Telegraf can receive topics. However, when another client disconnects, the 60-second timer in Cerbo is activated, and after this time, publishing of MQTT topics stops.

Therefore, some client must periodically publish a keep-alive request (in less than 60 seconds). Sending some kind of PINGREQ does not affect whether or not the Cerbo keeps publishing. I also experimented with MQTT Explorer and Mosquitto; these two are capable of publishing keep-alive requests, but this must be done periodically and manually. VRM is a special case because it does this automatically and periodically on behalf of the user.

The conclusion for other dummies like me is that, since Telegraf’s inputs.mqtt_consumer is subscriber-only, it is not capable of publishing a keep-alive request. However, you can use any other publisher to do this periodically and then Telegraf will act as a black passenger :slight_smile:

The easiest way is to use Node-RED to do this.

Note: MQTT topic is case sensitive. Must begin with uppercase ‘R’.