Use Grafana with InfluxDB OSS
Use Grafana or Grafana Cloud to visualize data from your InfluxDB instance.
The instructions in this guide require Grafana Cloud or Grafana v7.1+.
- Start InfluxDB OSS 2.1.
- Sign up for Grafana Cloud or download and install Grafana.
- Visit your Grafana Cloud user interface (UI) or, if running Grafana locally, start Grafana and visit
http://localhost:3000
in your browser. - In the left navigation of the Grafana UI, hover over the gear icon to expand the Configuration section. Click Data Sources.
- Click Add data source.
- 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 one of the following:
Configure Grafana to use Flux
With Flux selected as the query language in your InfluxDB data source, configure your InfluxDB connection:
Under Connection, enter the following:
URL: Your InfluxDB URL.
http://localhost:8086/
Organization: Your InfluxDB organization name or ID.
Token: Your InfluxDB API token.
Default Bucket: The default bucket to use in Flux queries.
Min time interval: The Grafana minimum time interval.
Click Save & Test. Grafana attempts to connect to the InfluxDB 2.1 datasource and returns the results of the test.
Configure Grafana to use InfluxQL
To query InfluxDB OSS 2.1 with InfluxQL, find your use case below, and then complete the instructions to configure Grafana:
- Installed a new InfluxDB 2.1 instance
- Upgraded from InfluxDB 1.x to 2.1 (following the official upgrade)
- Manually migrated from InfluxDB 1.x to 2.1
Installed a new InfluxDB instance
To configure Grafana to use InfluxQL with a new install of InfluxDB 2.1, do the following:
Upgraded from InfluxDB 1.x to 2.x
To configure Grafana to use InfluxQL when you’ve upgraded from InfluxDB 1.x to InfluxDB 2.1 (following an official upgrade guide):
- Authenticate using the non-admin v1 compatible authentication credentials created during the upgrade process.
- Use the DBRP mappings InfluxDB automatically created in the upgrade process (no action necessary).
Manually migrated from InfluxDB 1.x to 2.x
To configure Grafana to use InfluxQL when you’ve manually migrated from InfluxDB 1.x to InfluxDB 2.1, do the following:
- If your InfluxDB 1.x instance required authentication, create v1 compatible authentication credentials to match your previous 1.x username and password. Otherwise, use InfluxDB v2 token authentication.
- Manually create DBRP mappings.
View and create InfluxDB v1 authorizations
InfluxDB OSS 2.1 provides a 1.x compatible authentication API that lets you authenticate with a username and password like InfluxDB 1.x (separate from the credentials used to log into the InfluxDB user interface).
View existing v1 authorizations
Use the influx v1 auth list to list existing InfluxDB v1 compatible authorizations.
influx v1 auth list
Create a v1 authorization
Use the influx v1 auth create command to grant read/write permissions to specific buckets. Provide the following:
- bucket IDs to grant read or write permissions to
- new username
- new password (when prompted)
influx v1 auth create \
--read-bucket 00xX00o0X001 \
--write-bucket 00xX00o0X001 \
--username example-user
View and create InfluxDB DBRP mappings
When using InfluxQL to query InfluxDB, the query must specify a database and a retention policy. InfluxDB DBRP mappings associate database and retention policy combinations with InfluxDB 2.1 buckets.
DBRP mappings do not affect the retention period of the target bucket. These mappings allow queries following InfluxDB 1.x conventions to successfully query InfluxDB 2.1 buckets.
View existing DBRP mappings
Use the influx v1 dbrp list to list existing DBRP mappings.
influx v1 dbrp list
Create a DBRP mapping
Use the influx v1 dbrp create command command to create a DBRP mapping. Provide the following:
- database name
- retention policy name (not retention period)
- bucket ID
- (optional)
--default
flag if you want the retention policy to be the default retention policy for the specified database
Examples
DB with one RP DB with multiple RPs
influx v1 dbrp create \
--db example-db \
--rp example-rp \
--bucket-id 00xX00o0X001 \
--default
# Create telegraf/autogen DBRP mapping with autogen
# as the default RP for the telegraf DB
influx v1 dbrp create \
--db telegraf \
--rp autogen \
--bucket-id 00xX00o0X001 \
--default
# Create telegraf/downsampled-daily DBRP mapping that
# writes to a different bucket
influx v1 dbrp create \
--db telegraf \
--rp downsampled-daily \
--bucket-id 00xX00o0X002
For more information about DBRP mapping, see Database and retention policy mapping.
Configure your InfluxDB connection
With InfluxQL selected as the query language in your InfluxDB data source settings:
Under HTTP, enter the following:
URL: Your InfluxDB URL.
http://localhost:8086/
Access: Server (default)
Configure InfluxDB authentication:
Token authentication
Under Custom HTTP Headers, select Add Header. Provide your InfluxDB API token:
Header: Enter
Authorization
Value: Use the
Token
schema and provide your InfluxDB API token. For example:Token y0uR5uP3rSecr3tT0k3n
Authenticate with username and password
Under InfluxDB Details, do the following:
- Database: Enter the database name mapped to your InfluxDB 2.1 bucket
- User: Enter the username associated with your InfluxDB 1.x compatibility authorization
- Password: Enter the password associated with your InfluxDB 1.x compatibility authorization
- HTTP Method: Select GET
- Click Save & Test. Grafana attempts to connect to the InfluxDB 2.1 data source and returns the results of the test.
Query and visualize data
With your InfluxDB connection configured, use Grafana and Flux to query and visualize time series data stored in your InfluxDB instance.
For more information about using Grafana, see the Grafana documentation. If you’re just learning Flux, see Get started with Flux.