Use Grafana with InfluxDB OSS

The instructions in this guide require Grafana Cloud or Grafana v7.1+.

  1. Start InfluxDB OSS 2.2.
  2. or download and install Grafana.
  3. Visit your Grafana Cloud user interface (UI) or, if running Grafana locally, and visit in your browser.
  4. In the left navigation of the Grafana UI, hover over the gear icon to expand the Configuration section. Click Data Sources.
  5. Click Add data source.
  6. Select InfluxDB from the list of available data sources.
  7. On the Data Source configuration page, enter a name for your InfluxDB data source.
  8. Under Query Language, select one of the following:

Flux

With Flux selected as the query language in your InfluxDB data source, configure your InfluxDB connection:

  1. Under Connection, enter the following:

    • URL: Your InfluxDB URL.

    • Organization: Your InfluxDB .

    • Default Bucket: The default bucket to use in Flux queries.

    • Min time interval: The .

  1. Click Save & Test. Grafana attempts to connect to the InfluxDB 2.2 datasource and returns the results of the test.

To query InfluxDB OSS 2.2 with InfluxQL, find your use case below, and then complete the instructions to configure Grafana:

  1. .
  2. Manually create DBRP mappings.

To configure Grafana to use InfluxQL when you’ve upgraded from InfluxDB 1.x to InfluxDB 2.2 (following an ):

  1. Authenticate using the non-admin v1 compatible authentication credentials created during the upgrade process.
  2. Use the DBRP mappings InfluxDB automatically created in the upgrade process (no action necessary).

To configure Grafana to use InfluxQL when you’ve manually migrated from InfluxDB 1.x to InfluxDB 2.2, do the following:

  1. If your InfluxDB 1.x instance required authentication, to match your previous 1.x username and password. Otherwise, use InfluxDB v2 token authentication.
  2. .

View and create InfluxDB v1 authorizations

InfluxDB OSS 2.2 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 to list existing InfluxDB v1 compatible authorizations.

  1. influx v1 auth list

Create a v1 authorization

Use the 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)

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.2 .

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.2 buckets.

View existing DBRP mappings

Use the to list existing DBRP mappings.

  1. influx v1 dbrp list

Create a DBRP mapping

Use the 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

  1. # Create telegraf/autogen DBRP mapping with autogen
  2. # as the default RP for the telegraf DB
  3. --db telegraf \
  4. --bucket-id 00xX00o0X001 \
  5. --default
  6. # Create telegraf/downsampled-daily DBRP mapping that
  7. influx v1 dbrp create \
  8. --db telegraf \
  9. --rp downsampled-daily \
  10. --bucket-id 00xX00o0X002

For more information about DBRP mapping, see Database and retention policy mapping.

With InfluxQL selected as the query language in your InfluxDB data source settings:

  1. Under HTTP, enter the following:

    • URL: Your .

    • Access: Server (default)

  2. Configure InfluxDB authentication:

    • Token authentication

      Under Custom HTTP Headers, select Add Header. Provide your InfluxDB API token:

      • Header: Enter Authorization

      • Value: Use the schema and provide your . For example:

        1. Token y0uR5uP3rSecr3tT0k3n
    • Authenticate with username and password

      Under InfluxDB Details, do the following:

Use Grafana - 图2

  1. Click Save & Test. Grafana attempts to connect to the InfluxDB 2.2 data source and returns the results of the test.

For more information about using Grafana, see the Grafana documentation. If you’re just learning Flux, see .