Can Grafana fetch directly from MQTT... and store data?

  • What Grafana version and what operating system are you using?
    Current release, on Linux

  • What are you trying to achieve?
    Trying to get Grafana to read temperature+humidity sensor data from zigbee2mqtt - aggregate data for a week at higher resolution, and store data for months/years at lower resolution.

  • How are you trying to achieve it?
    This is what I don’t know - if I use MQTT addon for Grafana, can it automatically fetch the data, and store it in (some local) database at higher sample frequency for last week, and a lower sample frequency for an long-time database ? - or do I need something else to populate the DB’s properly first?

@andrekjellstrup Welcome to the Grafana forum.

The situation you describe (high resolution storage for more recent data, and lower resolution for months/years) is exactly what InfluxDB is great for. Have you explored using that for your application?

Re: MQTT, you could use this plugin to use Telegraf to collect your MQTT data and send it to InfluxDB, or you could use these nodes in Node-RED to collect your Zigbee2MQTT data and this node to send it to InfluxDB.

The MQTT datasource plugin for Grafana, which does indeed work, is still very much a beta product, despite being released a few years ago. It is just for viewing live, ephemeral data. Basically you point Grafana to your MQTT broker, define the topic, and voila! you are viewing the live MQTT data.

I am personally a fan of the Node-RED method as it’s easy to get started and their forum is excellent. InfluxDB community forum is also good.

@andrekjellstrup If it’s mqtt to mysql I have a solution for you!
cMqtt2Mysql2 from my project will do.
It’s a implemented in C a bridge. mqtt to mysql.

It’s really fast.
store all traffic in mysql, every topic separate table.
id, msg, entryDate
topic_[topic from mqtt with no space instead _]
options to dump topics.
buff ore data dump to db every 5 sec.

You can find cMqtt2Mysql2 at my repo GitHub - yOyOeK1/oiyshTerminal: off-line iot collection
you will find there a directory in main path.

as a dependency it’s need libmosquitto, mysql

Give it a try and let me know!

Example how it’s working in version 1.

Hi

I just read your project I am looking to get my PWS data that I have a MQTT connect to my Mysql and Grafana in Node Red

I am struggling to make work it allways refuse to connect to the database. I am using Windows 10 as operating system.

Do you thing that you may hekp me, Let me know I you may and I will send all what I have done in node red.

Welcome @tele to the Grafana forum.

Do you mean that you cannot Grafana to your MySQL database? Or that Node-RED cannot connect to MySQL?

Node red cannot connect to MYSQL

If you have not already done so, I would recommend you post that question on the Node-RED forum.