The MQTT data source plugin allows you to visualize streaming MQTT data from within Grafana.
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 |
TLS are used by IOT brokers such as AWS IOT Core. In order to connect, use the tls connection scheme.
Field | Description |
---|---|
Root certificate | (Optional) The path to the root certificate on the server |
Private Key Path | (Optional) The path to the private key file on the server |
Certificate Path | (Optional) The path to the certificate file on the server |
It is possible to subscribe to topic such as TOPIC/# in order to subscribe to a subtree of messages by using the keyword _WILDCARD_ in place of the # char.
The subscription becomes: DATA/_WILDCARD_ (Double underscore before and after WILDCARD
)
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.