The MQTT data source plugin allows you to visualize streaming MQTT data from within Grafana.
This plugin does not provide a storage for your events. It means, that if you want to query your historical data - this plugin is not for you. This datasource provides you an access to MQTT connetcion, which could be used to get Retained topics, but NOT intended to work with historical data. If you want to work with historical data please take a look for some storage engine like Loki to store events that you recieve from MQTT.
The MQTT data source has the following requirements:
- Grafana user with a server or organization administration role; refer to Permissions.
- Access to a MQTT broker.
Add a data source by filling in the following fields:
Field | Description |
---|---|
Name | A name for this particular MQTT data source |
URI | The scheme, host, and port of the MQTT Broker. Supported schemes: TCP (tcp://), TLS (tls://), and WebSocket (ws://) |
Field | Description |
---|---|
Username | (Optional) The username to use when connecting to the MQTT broker |
Password | (Optional) The password to use when connecting to the MQTT broker |
The query editor allows you to specify which MQTT topics the panel will subscribe to. Refer to the MQTT v3.1.1 specification for more information about valid topic names and filters.
- The plugin currently does not support all of the MQTT CONNECT packet options.
- This plugin automatically supports topics publishing numbers, strings, booleans, and JSON formatted values. Nested object values can be extracted using the
Extract Fields
transformation. - This plugin automatically attaches timestamps to the messages when they are received. Timestamps included in the message body can be parsed using the
Convert field type
transformation.
Refer to: Building a Streaming Datasource Backend Plugin
This plugin currently supports MQTT v3.1.x.
Note: Since this plugin uses the Grafana Live Streaming API, make sure to use Grafana v8.0+
- Clone the plugin to your Grafana plugins directory.
- Build the plugin by running
yarn install
and thenyarn build
.
NOTE: The yarn build
command above might fail on a non-unix-like system, like Windows, where you can try replacing the rm -rf
command with rimraf
in the ./package.json
file to make it work.
- Run
mage reloadPlugin
or restart Grafana for the plugin to load.
- In Grafana from the left-hand menu, navigate to Configuration > Data sources.
- From the top-right corner, click the Add data source button.
- Search for
MQTT
in the search field, and hover over the MQTT search result. - Click the Select button for MQTT.