InfluxDB 2.x: Map unmapped buckets (DBRP / InfluxDB 1.x compatibility)
Aus Wiki-WebPerfect
Version vom 1. Februar 2022, 15:13 Uhr von Admin (Diskussion | Beiträge)
If you want to query an InfluxDB 2.x with the query language InfluxQL you have to create a map for your bucket.
In InfluxDB 1.x, data is stored in databases and retention policies. In InfluxDB OSS 2.0, data is stored in buckets. Because InfluxQL uses the 1.x data model, before querying in InfluxQL, a bucket must be mapped to a database and retention policy (DBRP).
If you don't create this mapping, an error will occurs, because influx can't find the database.
API
curl --request POST http://localhost:<INFLUXDB_PORT>/api/v2/dbrps \ --header "Authorization: Token <YOUR_TOKEN>" \ --header 'Content-type: application/json' \ --data '{ "bucketID": "<YOUR_BUCKET_ID>", "database": "<YOUR_BUCKET_NAME>", "default": true, "orgID": "<YOUR_ORGANISATION_ID>", "retention_policy": "<YOUR_RETENTION_POLICY_FOR_MAPPING>" }'
Source: https://docs.influxdata.com/influxdb/v2.1/query-data/influxql/#map-unmapped-buckets
CLI
influx v1 dbrp create \ --db <YOUR_BUCKET_NAME> \ --rp <YOUR_RETENTION_POLICY_FOR_MAPPING> \ --bucket-id <YOUR_BUCKET_ID> \ --default
Important
Following InfluxQL queries are unsupported:
- SELECT INTO
- ALTER
- CREATE
- DROP (limited support)
- GRANT
- KILL
- REVOKE
List all retention policy mappings
API
curl --request GET http://localhost:<INFLUXDB_PORT>/api/v2/dbrps?orgID=<YOUR_ORGANISATION_ID> \ --header "Authorization: Token <YOUR_TOKEN>" \
CLI
influx v1 dbrp list --org-id <YOUR_ORGANISATION_ID> -t <YOUR_TOKEN>
Remove a retention policy mapping
CLI
influx v1 dbrp delete --id <DBRP_ID> --org-id <YOUR_ORGANISATION_ID> -t <YOUR_TOKEN>