Skip to content

Grafana

Grafana Overview

Grafana is an open-source visualization tool. It allows you to create dashboards for your data. Grafana can easily integrate with InfluxDB due to the provided datasource plug-in, which connects to and streams data from InfluxDB.

For further information on Grafana, refer to the Grafana documentation.

Grafana Example

This example demonstrates how to set up and use Grafana. Before using Grafana you need to set up Edge Xpert export data to InfluxDB. The steps for exporting data from the Virtual Device Service to InfluxDB are described in the InfluxDB example. Ensure you have done this first.

To visualize the readings in grafana, the following complete the following steps:

  1. Start Grafana
  2. Add a data source
  3. Create a dashboard

Start Grafana

Start Grafana using the following command:

edgexpert up grafana

Add a Data source

To use Grafana to visualize the data we need to add a datasource. The datasource will be the InfluxDB database where the Edge Xpert events are being sent.

To add a datasource, complete the following steps:

  1. Open a web browser.
  2. In the Address Bar of your browser, enter

    http://localhost:3000/login

    The Grafana login screen displays.

    Note

    The port number can be configured in the docker-compose.yml file

  3. In the login screen, enter admin as both username and password, as illustrated below:

    Grafana Login Screen

    The Grafana Home Dashboard displays

  4. Select Add Your First Data Source or Select Configuration > Data sources as illustrated below:

    Grafana add data source screen

  5. Choose InfluxDB from the list of data sources

    Grafana choose data source screen

  6. Enter the information in the Add Data source screen. To set up the data source for this example, use the following values or your custom InfluxDB configurations:

    Field Values
    Name Influx
    Query Language Flux
    URL http://influxdb:8086
    Basic Auth Disable
    Organization my-org
    Token custom-token
    Default Bucket my-bucket

    Click "Save and Test" It should say buckets found, as illustrated below. Grafana database buckets found

    If this message does not display, double-check the entries in the fields and try again.

Create a Dashboard

To create a dashboard, complete the following steps:

  1. Select Create (+) > Dashboard
  2. On the Edit Panel page, choose InfluxDB as the data source
  3. Enter the following script in the query script editor and click the apply button.
    from(bucket: "my-bucket")
      |> range(start: -15m)
      |> filter(fn: (r) => r["_measurement"] == "readings" and r["resourceName"] == "Float32")
      |> group(columns: ["resourceName"])
      |> sort(columns: ["_time"])
    

The following illustration shows the resultant graph:

Grafana dashboard

Back to top