DEV Community

PeterMilovcik
PeterMilovcik

Posted on • Edited on

How to Create a Bucket With InfluxDB v2.1 CLI

There are a couple of changes in InfluxDB CLI if you upgrade from 1.X to 2.1. The database is now called a "bucket," and it's pretty different when creating one using CLI. Here is what I've learned the hard way (by trial & error and googling):

There is no
influx -execute 'SHOW DATABASES'
or influx -execute 'CREATE DATABASE Foo'.

There are buckets instead, and you need permission to create one:
influx auth create -o MyOrg --write-buckets

In v2.1, I have not found any --all-access flag.

If you have permission, create a bucket:
influx bucket create -n BucketName -o MyOrg -r 7d

When you try to import data to your new bucket and import fails with an error message Not Found {"code":"not found","message":"no dbrp mapping found"} you need to create a mapping from bucket to retention policy.

DBRP stands for "Database and Retention Policy"

(Shouldn't that be also changed to Bucket and Retention Policy (BRP)?)

Here is how you can create a mapping between a bucket and DBRP for a "week":

First, if you don't have one already, you need permission:
influx auth create -o MyOrg --write-dbrps

Second, create a mapping:
influx v1 dbrp create --db BucketName --rp week --bucket-id mybucketid --default

And that's it. Import should be successful now.

I'm still a newbie with the InfluxDB. If you have a better way to do this or I miss something, let me know in the comments. I'd love to learn more!

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay