Visualize Data Using Grafana
You can use Grafana to visualize data in Litmus Edge.
You have two options to install the Docker container.
If you have access to Litmus Edge Manager (LEM), you can use LEM to deploy Grafana in your Litmus Edge instance.
To deploy Grafana from Litmus Edge Manager:
- In Litmus Edge Manager, follow the steps to Manage Applications. For Grafana, follow the steps to Deploy an Application to Edge Devices.
- For Step 2: Application Settings, if the default port number is already in use, you will need to enter another port.
- In Litmus Edge, navigate to Applications > Containers. The Containers pane appears.
- Verify that the Grafana Docker Container is running.
If you don't have access to Litmus Edge Manager, you can run the Grafana container in Litmus Edge.
To run the Grafana container in Litmus Edge:
- Navigate to Applications > Containers. The Containers pane appears.
- From the Containers pane, click Run. The Enter command to run field appears.
- Enter the following Docker run command and click Run.
If needed, replace -p 3000:3000 with a different port.
4. Verify that the Grafana Docker Container is running.
To connect to Grafana, you will use your Litmus Edge IP address and the port configured in the Grafana container.
To access Grafana:
- In a new browser window, enter the URL to connect to Grafana using this format: [Litmus Edge IP address]:[port]. For example, if your Litmus Edge instance uses the IP address https://192.168.0.146, and the Grafana container uses port 3000, enter 192.168.0.146:3000. The Grafana login screen appears.
- Enter admin as the username and password, and then change the password. The Grafana Home screen appears.
Grafana needs a database to extract from to display results. Litmus Edge allows you to configure the internal timeseries database (tsdata) to connect to Grafana.
You also have the option to set up a database to your specific requirements.
You will need to create a user that has read access to the database.
To create a DB user:
- In Litmus Edge, navigate to DataHub > DB Users.
Click the Add user icon.
- Configure the user details.
- Username
- Password: Copy and save this for later use.
- Database: Select tsdata.
- Privilege: Select Read.
- Click Add User.
The database will not connect successfully to Grafana unless at least one measurement is in the database.
To confirm if the database has a measurement, navigate to DataHub > DB Management and click the arrow to expand the tsdata database.
If there are no measurements listed, follow the steps below.
Follow the steps to Connect a Device and do the following:
- Select the Device Type Simulator and the Driver Name Generator.
- Select the Enable Data Store check box in the device configuration.
- Enter a value in the Retention Hours field.
Follow the steps to Add Tags and add at least one tag to the device you created.
After connecting the device and adding the tag, navigate to DataHub > DB Management and click the arrow to expand the tsdata database again to confirm a measurement is now available.
You will need to add a data source in Grafana that connects to the database you created. See the Influx data source documentation from Grafana to learn more.
When configuring the data source, do the following:
- Select the InfluxDB time-series database.
- In the URL field, enter http://10.30.50.1:8086. 10.30.50.1 is the IP address of Litmus Edge on the internal docker network by default.
- In the Database field, enter tsdata.
- In the User field, enter the username you configured for the DB user in Litmus Edge.
- In the Password field, paste or enter the password you configured for the DB user in Litmus Edge.
Now that the database is successfully connected to Grafana, you can start visualizing the data by using a dashboard. See the Create a dashboard documentation from Grafana to learn more.