Show mqtt JSON messages in Grafana

We have a running setup with a K3S Cluster, Telegraf for metrics pushed to mqtt and Grafana to show these metrics. We don’t need historical data, so we do not have a InfluxDB installed.
Our problem is, that we can see the JSON messages in Grafana, but we have no clue how to parse them and show them in a dashboard.

MQTT message (e.g. memory):


As you can see, Grafana gets all the information from the message and if we use this query as a base for a Time Series Dashboard, it will only show the value of “timestamp”.
But we want to show the value for “available_percent” for example and in the next step, show this percentage value for all of our four K3S nodes.
Any help is much appreciated :slight_smile:

There is probably a Telegraf method to parse the MQTT message and separate out what you want, but I would personally do this in NodeRED. Have you considered that option?

Hi @grant2

thanks for your reply.
No, not at the moment.
We wanted the cluster as small as possible due to resource limitations.
But I’ll check the Telegraf output.

Markus: NodeRED is dead easy to get going and for what you want to do, it would be a simple flow like this:

I do not have the MQTT datasource plugin installed right now (it’s running on another system though, but I won’t have access until tonight). Basically I would set it up to subscribe to the topic “available_percent”.

Hi @grant2

what settings do you have in “set msg.payload” and the outgoing mqtt “available_percent”?
Never worked with node-red before :slight_smile:

So in my example, I was sending the entire JSON array (just as you posted). That is what shows up in the first Debug node.

The object that you want (in your example) is available_percent, which is msg.payload.fields.available_percent, so I put a Change node in there and set the msg.payload to be msg.payload.fields.available_percent:

Then it will pass that one object to the MQTT broker (circled in black). You could send other objects as well and regulate the frequency of how often to check or resend the value:

Here is what the MQTT node settings (the purple one) look like. Basically just enter the IP address of your MQTT broker and set the topic that you want to use:

ok, that works.
Changed “Inject” to “mqtt in” and it works as well.
I’ll try to grab this new message and import that to the Grafana dashboard.
If it works, then I’ll setup the node-red parse for all values that I need.
Thanks for your support :wink:

Great. Post back or direct message me if you get stuck.