Map databases and retention policies to buckets
InfluxQL requires a database and retention policy (DBRP) combination in order to query data. In InfluxDB Cloud Serverless, databases and retention policies are combined and replaced by InfluxDB buckets. To query an InfluxDB Cloud Serverless bucket with InfluxQL, first map each DBRP combination to a bucket.
- Automatic DBRP mapping
- Create DBRP mappings
- List DBRP mappings
- Update a DBRP mapping
- Delete a DBRP mapping
Automatic DBRP mapping
InfluxDB Cloud Serverless automatically creates DBRP mappings for you during the following operations:
For more information, see Database and retention policy mapping.
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 a database and retention policy to a bucket.
Include the following:
* Required
- * API token to authenticate. We recommend setting your 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, seeinflux 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 \
--token API_TOKEN \
--db DATABASE_NAME \
--rp RETENTION_POLICY_NAME \
--bucket-id BUCKET_ID \
--default
Use the /api/v2/dbrps
API endpoint
to create a new DBRP mapping.
POST https://cloud2.influxdata.com/api/v2/dbrps
Include the following:
- Request method:
POST
- Headers:
- Authorization:
Token
schema with your InfluxDB API token - Content-type:
application/json
- Authorization:
- 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 https://cloud2.influxdata.com/api/v2/dbrps \
--header "Authorization: Token API_TOKEN" \
--header 'Content-type: application/json' \
--data '{
"bucketID": "BUCKET_ID",
"database": "DATABASE_NAME",
"default": true,
"orgID": "ORG_ID",
"retention_policy": "RETENTION_POLICY_NAME"
}'
List DBRP mappings
Use the influx
CLI or the
InfluxDB HTTP 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.
View all DBRP mappings
influx v1 dbrp list --token API_TOKEN
Filter DBRP mappings by database
influx v1 dbrp list \
--token API_TOKEN \
--db DATABASE_NAME
Filter DBRP mappings by bucket ID
influx v1 dbrp list \
--token API_TOKEN \
--bucket-id BUCKET_ID
Use the /api/v2/dbrps
API endpoint to list DBRP mappings.
GET https://cloud2.influxdata.com/api/v2/dbrps
Include the following:
- Request method:
GET
- Headers:
- Authorization:
Token
schema with your InfluxDB API token
- Authorization:
- 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 \
https://cloud2.influxdata.com/api/v2/dbrps \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "orgID=ORG_ID"
Filter DBRP mappings by database
curl --request GET \
https://cloud2.influxdata.com/api/v2/dbrps \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "orgID=ORG_ID" \
--data-urlencode "db=DATABASE_NAME"
Filter DBRP mappings by bucket ID
curl --request GET \
https://cloud2.influxdata.com/api/v2/dbrps \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "orgID=ORG_ID" \
--data-urlencode "bucketID=BUCKET_ID"
Update a DBRP mapping
Use the influx
CLI or the
InfluxDB HTTP API to update a DBRP mapping.
Use the influx v1 dbrp update
command
to update a DBRP mapping.
Include the following:
* Required
- * API token to authenticate. We recommend setting your 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 \
--token API_TOKEN \
--id DBRP_ID \
--rp RETENTION_POLICY_NAME \
--default
Use the /api/v2/dbrps/{dbrpID}
API endpoint to update DBRP mappings.
PATCH https://cloud2.influxdata.com/api/v2/dbrps/{dbrpID}
Include the following:
* Required
- Request method:
PATCH
- Headers:
- * Authorization:
Token
schema with your InfluxDB API token
- * Authorization:
- Path parameters:
- * id: DBRP mapping ID to update
- Query parameters:
- * orgID: organization ID
- 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 \
https://cloud2.influxdata.com/api/v2/dbrps/DBRP_ID \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "orgID=ORG_ID" \
--data '{
"rp": "RETENTION_POLICY_NAME",
"default": true
}'
Delete a DBRP mapping
Use the influx
CLI or the
InfluxDB API to delete a DBRP mapping.
Use the influx v1 dbrp delete
command
to delete a DBRP mapping.
Include the following:
* Required
- * API token to authenticate. We recommend setting your 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 \
--token API_TOKEN \
--id DBRP_ID
Use the /api/v2/dbrps/{dbrpID}
API endpoint
to delete a DBRP mapping.
DELETE https://cloud2.influxdata.com/api/v2/dbrps/{dbrpID}
Include the following:
* Required
- Request method:
PATCH
- Headers:
- * Authorization:
Token
schema with your InfluxDB API token
- * Authorization:
- Path parameters:
- * id: DBRP mapping ID to update
- Query parameters:
- * orgID: organization ID
curl --request DELETE \
https://cloud2.influxdata.com/api/v2/dbrps/DBRP_ID \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "orgID=ORG_ID"
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.