These instructions will take you through setting up a Grafana dashboard connected to an InfluxDB data source using data from NodeRED.
In this lab you will
- Set Up Grafana
- Build InfluxDB database
- Connect to InfluxDB Data Source
- Create a basic Dashboard
You will need:
- Grafana
- InfluxDB v2.3 (at least v1.8+)
Since we're setting up a Grafana dashboard in this lab, we'll need to install Grafana. Please select your corresponding operating system and follow the instructions. Note: If you are using Debian, install here instead.
Next, you'll want to configure Grafana. Again, follow the instructions for your operating system. As noted in the configuration guide, you'll need to remove comments in the .ini files by removing the ;
at the beginning of the lines you want to change.
- Open your web browser and go to http://localhost:3000/. The default HTTP port that Grafana listens to is
3000
unless you configured a different port in the previous step. If you are not hosting Grafana locally, then go tohttp://[host]:3000/
instead. - On the login page, enter
admin
as the username and password. - Click Log in. If the login is successful, you will see a prompt to change the password.
- Click OK on the prompt, then change your password.
Before you start displaying data on your dashboard, you will need to first build a database that you can query your data from. We will be using InfluxDB to do this. Start by installing InfluxDB v2.3 by selecting the corresponding operating system and following the instructions to download and install both InfluxDB and the influxCLI.
Once you get to the Start InfluxDB section, if ./influxd
command not working, check to see if the influxd.exe is in the current directory. If not, you may need to cd
into influxdb2-2.3.0-windows-amd64 before running the command
You have the option of setting up InfluxDB either through the UI or CLI. Note that in the latest version of InfluxDB (v2.3), a bucket is a named location where time series data is stored. It’s similar to an InfluxDB v1.x “database,” but is a combination of both a database and a retention policy.
- Move your cursor to the cog icon on the side menu which will show the configuration options.
- Click on Data sources. The data sources page opens showing a list of previously configured data sources for the Grafana instance.
- Click Add data source to see a list of all supported data sources.
- Select InfluxDB from the list of available data sources.
- On the Data Source configuration page, enter a name for your InfluxDB data source.
- Under Query Language, select Flux.
- Under HTTP, enter the following:
- URL: Your InfluxDB URL.
- Access: Server (default)
- Under Auth, turn the Basic auth toggle on.
- Under Basic Auth Details, enter the username and password you made during your InfluxDB setup next to User and Password respectively.
- Under InfluxDB Details, enter the following:
- Organization: Your InfluxDB organization ID.
- Token: Your InfluxDB API token.
- Default Bucket: The default bucket to use in Flux queries.
- Min time interval: The Grafana minimum time interval. Default is
10s
- Max series: The maximum number of series or tables Grafana will process. Default is
1000
.
- Click Save & Test. Grafana attempts to connect to the InfluxDB 2.3 datasource and returns the results of the test.
- Click the New dashboard item under the Dashboards icon in the side menu.
- On the dashboard, click Add a new panel.
- Under the Query tab, select your InfluxDB data source from the data source selector.
- In the following box, use Flux to query data from InfluxDB.
- You can also use the InfluxDB GUI to help you generate your query by selecting the
_measurement
and_field
you want to pull from your database. - Click Submit on the right side to see a visualization of your query, and the Script Editor button will generate the query in Flux.
- Then copy and paste the Flux query into the box in Grafana.
- You can also use the InfluxDB GUI to help you generate your query by selecting the
- On the right side there is an option pane where you can change the type of visualization, add a panel title, and edit other panel settings.
- Once you've finished making the panel, click Save at the top right of your screen to save the dashboard.
- Add a name for your dashboard, then click Save.
Congratulations, you have created your first dashboard and it is displaying results!