Grafana and MQTT for home IOT

Looking for advice on approach - I’m using MQTT with my home built IOT devices for home automation for debugging and support. (Note: using Smartthings and custom drivers I write and not Home Assistant). I’m looking for a dashboarding mechanism for debugging and extended monitoring. I’ve tried Grafana with the MQTT beta plugin which does live feed. What are my options to persist the MQTT data for adhoc queries (debug) and general dashboards? Some kind of Agent? Loki? I’ve used Splunk in the past and in that I would probably use a “insert into” in a query to persist live data. What’s the approach for Grafana?

Welcome @specialed2000

I think in order to “persist the MQTT data” you are really asking which datasource / database (to store the data) would be best, right? For that, I think Prometheus is probably the most widely used one with Grafana, but InfluxDB, Graphite, Zabbix and other datasources are all very well supported.

I also have MQTT data flying around everywhere and when the MQTT beta plugin does not meet my needs (as you have found), my go-to is to use Node-RED, which is basically like a lightweight agent that can easily take your MQTT data, massage / reformat it if need be, then send it to a datasource of your choice. I have working examples of doing this with Prometheus, Graphite and InfluxDB and can elaborate if that is indeed what you think you’d like to do. The Node-RED forum is also excellent.

Looks like Prometheus is the best match. I did find a prometheus mqtt bridge and tried it with Loki, but turns out Loki doesn’t support http style static exporters. What I have will get me going and then I’ll do my own as you suggested since I think some of the more “messy” error logs will need a bit of processing to make them useable.

Highly recommend you do this in node red, where you’ll have complete control of the Prometheus exporter. Your node red instance will subscribe to the mqtt topics you set up and it will create a /metrics endpoint on your node red instance where the metrics will be published.

Set up a Prometheus instance to scrape these metrics.

In Granada, I think the mistake you are making is trying to work with Loki. This sounds like time series data, not logs. Loki is for logs. In Grafana simply setup a new data source and point it at your Prometheus instance where you should be able to see all your data. Note you’ll have to modify the default scrape frequency, depending on how fast your data changes.

Yep, I agree being able to have complete control is important. I do need logs however, so I’m going to go back to looking at Loki. My Smartthings app already satisfies most of my dashboard needs for home automation, but what I want are stats that it won’t cover like how many times a device has rebooted. But the really critical part are debug logs and that looks much more like Loki kind of work.