Documentation

Manage DBRP mappings

InfluxQL requires a database and retention policy (DBRP) combination to query data from. In InfluxDB 2.4, databases and retention policies have been combined and replaced by InfluxDB buckets. To query an InfluxDB 2.4 with InfluxQL, the specified DBRP combination must be mapped to a bucket.

Automatic DBRP mapping

InfluxDB 2.4 will automatically create DBRP mappings for you during the following operations:

For more information, see Database and retention policy mapping.

Virtual DBRP mappings

InfluxDB 2.4 provides “virtual” DBRP mappings for any bucket that does not have an explicit DBRP mapping associated with it. Virtual DBRP mappings use the bucket name to provide a DBRP mapping that can be used without having to explicitly define a mapping.

Virtual DBRP mappings are read-only. To override a virtual DBRP mapping, create an explicit mapping.

For information about how virtual DBRP mappings are created, see Database and retention policy mapping – When creating a bucket.

Create DBRP mappings

Use the influx CLI or the InfluxDB API to create DBRP mappings.

A DBRP combination can only be mapped to a single bucket

Each unique DBRP combination can only be mapped to a single bucket. If you map a DBRP combination that is already mapped to another bucket, it will overwrite the existing DBRP mapping.

Use the influx v1 dbrp create command to map an unmapped bucket to a database and retention policy. Include the following:

* Required

  • * org and token to authenticate. We recommend setting your organization and token to your active InfluxDB connection configuration in the influx CLI, so you don’t have to add these parameters to each command. To set up your active InfluxDB configuration, see influx config set.
  • * database name to map
  • * retention policy name to map
  • * Bucket ID to map to
  • Default flag to set the provided retention policy as the default retention policy for the database
influx v1 dbrp create \
  --db example-db \
  --rp example-rp \
  --bucket-id 00oxo0oXx000x0Xo \
  --default

Use the /api/v2/dbrps API endpoint to create a new DBRP mapping.

POST http://localhost:8086/api/v2/dbrps

Include the following:

  • Request method: POST
  • Headers:
    • Authorization: Token schema with your InfluxDB API token
    • Content-type: application/json
  • Request body: JSON object with the following fields:
    * Required
    • * bucketID: bucket ID
    • * database: database name
    • default: set the provided retention policy as the default retention policy for the database
    • * org or orgID: organization name or organization ID
    • * retention_policy: retention policy name
curl --request POST http://localhost:8086/api/v2/dbrps \
  --header "Authorization: Token YourAuthToken" \
  --header 'Content-type: application/json' \
  --data '{
        "bucketID": "00oxo0oXx000x0Xo",
        "database": "example-db",
        "default": true,
        "orgID": "00oxo0oXx000x0Xo",
        "retention_policy": "example-rp"
      }'

List DBRP mappings

Use the influx CLI or the InfluxDB API to list all DBRP mappings and verify the buckets you want to query are mapped to a database and retention policy.

Use the influx v1 dbrp list command to list DBRP mappings.

The examples below assume that your organization and API token are provided by the active InfluxDB connection configuration in the influx CLI. If not, include your organization (--org) and API token (--token) with each command.

View all DBRP mappings
influx v1 dbrp list
Filter DBRP mappings by database
influx v1 dbrp list --db example-db
Filter DBRP mappings by bucket ID
influx v1 dbrp list --bucket-id 00oxo0oXx000x0Xo

Use the /api/v2/dbrps API endpoint to list DBRP mappings.

GET http://localhost:8086/api/v2/dbrps

Include the following:

  • Request method: GET
  • Headers:
    • Authorization: Token schema with your InfluxDB API token
  • Query parameters:
    * Required
    • * orgID: organization ID
    • bucketID: bucket ID (to list DBRP mappings for a specific bucket)
    • database: database name (to list DBRP mappings with a specific database name)
    • rp: retention policy name (to list DBRP mappings with a specific retention policy name)
    • id: DBRP mapping ID (to list a specific DBRP mapping)
View all DBRP mappings
curl --request GET \
  http://localhost:8086/api/v2/dbrps?orgID=00oxo0oXx000x0Xo \
  --header "Authorization: Token YourAuthToken"
Filter DBRP mappings by database
curl --request GET \
  http://localhost:8086/api/v2/dbrps?orgID=00oxo0oXx000x0Xo&db=example-db \
  --header "Authorization: Token YourAuthToken"
Filter DBRP mappings by bucket ID
curl --request GET \
  https://cloud2.influxdata.com/api/v2/dbrps?organization_id=00oxo0oXx000x0Xo&bucketID=00oxo0oXx000x0Xo \
  --header "Authorization: Token YourAuthToken"

Update a DBRP mapping

Use the influx CLI or the InfluxDB API to update a DBRP mapping.

Virtual DBRP mappings cannot be updated. To override a virtual DBRP mapping, create an explicit mapping.

Use the influx v1 dbrp update command to update a DBRP mapping. Include the following:

* Required

  • * org and token to authenticate. We recommend setting your organization and token to your active InfluxDB connection configuration in the influx CLI, so you don’t have to add these parameters to each command. To set up your active InfluxDB configuration, see influx config set.
  • * DBRP mapping ID to update
  • Retention policy name to update to
  • Default flag to set the retention policy as the default retention policy for the database
Update the default retention policy
influx v1 dbrp update \
  --id 00oxo0X0xx0XXoX0
  --rp example-rp \
  --default

Use the /api/v2/dbrps/{dbrpID} API endpoint to update DBRP mappings.

PATCH http://localhost:8086/api/v2/dbrps/{dbrpID}

Include the following:

* Required

  • Request method: PATCH
  • Headers:
    • * Authorization: Token schema with your InfluxDB API token
  • Path parameters:
    • * id: DBRP mapping ID to update
  • Query parameters:
  • Request body (JSON):
    • rp: retention policy name to update to
    • default: set the retention policy as the default retention policy for the database
Update the default retention policy
curl --request PATCH \
  http://localhost:8086/api/v2/dbrps/00oxo0X0xx0XXoX0?orgID=00oxo0oXx000x0Xo \
  --header "Authorization: Token YourAuthToken"
  --data '{
      "rp": "example-rp",
      "default": true
    }'

Delete a DBRP mapping

Use the influx CLI or the InfluxDB API to delete a DBRP mapping.

Virtual DBRP mappings cannot be deleted.

Use the influx v1 dbrp delete command to delete a DBRP mapping. Include the following:

* Required

  • * org and token to authenticate. We recommend setting your organization and token to your active InfluxDB connection configuration in the influx CLI, so you don’t have to add these parameters to each command. To set up your active InfluxDB configuration, see influx config set.
  • * DBRP mapping ID to delete
influx v1 dbrp delete --id 00oxo0X0xx0XXoX0

Use the /api/v2/dbrps/{dbrpID} API endpoint to delete a DBRP mapping.

DELETE http://localhost:8086/api/v2/dbrps/{dbrpID}

Include the following:

* Required

  • Request method: PATCH
  • Headers:
    • * Authorization: Token schema with your InfluxDB API token
  • Path parameters:
    • * id: DBRP mapping ID to update
  • Query parameters:
curl --request DELETE \
  http://localhost:8086/api/v2/dbrps/00oxo0X0xx0XXoX0?orgID=00oxo0oXx000x0Xo \
  --header "Authorization: Token YourAuthToken"

Was this page helpful?

Thank you for your feedback!


Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.