Litmus Edge Data Source for Grafana
Litmus Edge publishes device data to NATS topics. The Litmus Edge data source plugin subscribes to those topics and streams the values into Grafana panels as they arrive. This page installs the plugin, connects it to Litmus Edge, and shows live data in a panel.
Install
Before You Start
- Litmus Edge v3.16 or later. The tested series is 4.4.x (verified on 4.4.2).
- For the standalone image, Docker on a Linux amd64 or arm64 host with access to litmusedge.azurecr.io. Use host port 3000 or another free port. To run inside Litmus Edge, run Docker on the Litmus Edge host.
- For the plugin alone, Grafana v12.2 or later on Linux amd64 or arm64, shell access to its host or container, and permission to restart Grafana.
- A data point publishing to NATS. Grafana must be able to reach the NATS Proxy on TCP port 4222 by default. For an external connection, enable the NATS Proxy and create an Access Account with read access to the topics you plan to stream, or use a message broker token with the same permissions.
- For topic discovery, create a separate Litmus Edge API token and make sure Grafana can reach the Litmus Edge HTTPS endpoint (default TCP port 443). The Access Account token for NATS does not authenticate topic discovery.
Choose an Install Path
To add the plugin to a Grafana instance you already run, use the Existing Grafana tab and continue with the next section. To start a new Grafana with the plugin preinstalled, use the litmus-grafana image tab.
Install the plugin in your Grafana instance, then connect it to Litmus Edge. Continue with Install the Plugin below.
Install the Plugin
- Download litmus-edge-datasource-0.2.1.zip from Litmus Grafana downloads in Central.
- Copy the ZIP to the Grafana host or container and run the following command there. If you use a custom Grafana plugins directory, replace the default path.
unzip litmus-edge-datasource-0.2.1.zip -d /var/lib/grafana/plugins/- Restart Grafana. The Litmus Edge data source type appears when you add a data source.
The release plugin is signed for http://localhost:3000, http://localhost:3001, http://localhost:3002, http://localhost:8080, and http://localhost:8443. Set Grafana root_url to the matching URL before restarting. To test an unsigned local build, set GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=litmus-edge-datasource before restarting.
Connect to Litmus Edge
To add the data source, follow Add a data source in the Grafana documentation and select Litmus Edge. Then enter the connection details for your setup. To configure the data source from a file instead, use the provisioning YAML in the same tab.
Leave Remote Connection off and set these fields:
Field | Description |
|---|---|
Edge Docker Gateway IP | IP address Grafana uses to reach Litmus Edge. Default: 10.30.50.1. Change it if your Litmus Edge instance uses a different Docker gateway IP. The plugin does not detect it. |
API Token | Optional. Enables topic discovery in the query editor. |
To provision the data source, save this file in the Grafana provisioning directory:
apiVersion: 1
prune: true
datasources:
- name: Litmus Edge
type: litmus-edge-datasource
access: proxy
editable: true
jsonData:
externalEdge: false
gatewayIp: $EDGE_DOCKER_GATEWAY_IP
secureJsonData:
apiToken: $EDGE_API_TOKENSave the file as litmus-edge.yml in /etc/grafana/provisioning/datasources/, or use your configured provisioning path. Set the variables in the Grafana service environment, then restart Grafana. Use a different data source name if Litmus Edge already exists in the same Grafana organization.
Verify Your Setup
- On the data source settings page, click Save & test. Grafana shows Connected to the Edge. With an API Token set, the message ends with Topic discovery is working. Without one, it ends with Tip: add an API Token to enable topic discovery.
- Add a panel to a dashboard and select the Litmus Edge data source.
- In the Topic field, enter the NATS topic of a data point that is publishing, for example devicehub.alias.demo.bearing_temperature. With an API Token set, you can instead search for a topic and select it.
- Watch the panel. Values refresh about once per second while the topic is publishing.
The topic must be an exact NATS subject. Wildcards (* and >) are not supported. If the panel stays empty, see Troubleshooting.
Remove Litmus Grafana
For the standalone image:
- Export any dashboards you want to keep. Removing the container and its anonymous volumes deletes its Grafana data.
- Run docker rm -fv litmus-grafana.
- Run docker image rm litmusedge.azurecr.io/litmus-grafana:0.2.1 if no other container uses the image.
- Run docker ps -a --filter name=litmus-grafana. The removed container no longer appears.
For an existing Grafana instance:
- Remove any test panels or dashboards you created for this setup. If you added the data source in Grafana, open its settings and delete it. If you provisioned it with the example above, delete litmus-edge.yml. Grafana removes the provisioned data source at the next restart.
- Run grafana cli plugins remove litmus-edge-datasource, or delete the extracted litmus-edge-datasource directory from your Grafana plugins directory.
- Remove the downloaded ZIP with the same account that copied it to the host or container. Remove any Grafana environment or signature settings you added only for this plugin.
- Restart Grafana. Confirm the data source and plugin are no longer listed.
For either path, revoke any Access Account or API token you created only for this installation. If you created a simulator device only for verification, remove the device and its tags.
Troubleshooting
Symptom | Cause and fix |
|---|---|
Save & test fails and Grafana runs inside Litmus Edge | Edge Docker Gateway IP is wrong for this instance, or the Grafana container cannot reach Litmus Edge on port 4222. Check the IP and the container network. |
Save & test fails and Grafana connects to an external Litmus Edge | Litmus Edge is not reachable on the configured NATS Proxy Port, the NATS Proxy is disabled, or the Access Account API Key is invalid. Check each in that order. |
The panel shows no data | The topic is not an exact NATS subject, or no device is publishing to it. Remove any wildcard, confirm the device publishes, and look for Topic not found in the Grafana logs. |
The panel shows old values after a reconnect | NATS can buffer messages while Grafana is disconnected. Refresh the dashboard to clear them. |
The Grafana logs show Messages dropped (buffer full) | The topic produced more than 10,000 messages between updates. Query a more specific topic. |
To rotate a token set in Grafana, edit the data source, enter the new value, and click Save & test. If you supply the token through provisioning, update its environment variable as well. Grafana stores tokens in secure JSON data and does not return them to the browser.
What's Next
- Usage ā query several topics, use template variables, and map payload types to Grafana types
- Customizing legends ā name series from device and tag labels
- Known limitations ā live data only, no wildcard topics, one topic per query row