Buckets and Retention
Outcome: a second bucket with a
one-day memory, and a witnessed
demonstration of what happens to a
point that is older than its bucket
allows. Transcript:
influxdb-lab/transcripts/t05-buckets-and-retention.txt.
A bucket per purpose
A bucket is a named home for points,
with two properties that matter: it
belongs to one organisation, and it has
a retention rule — the age past
which its points are forgotten. The
setup's weather bucket has infinite
retention: it forgets nothing, ever,
and its disk bill grows forever with
it. Real systems split the difference:
raw readings kept briefly, summaries
kept long (chapter 9 builds exactly
that pair), and separate buckets for
separate jobs so each can keep its own
schedule.
influx bucket create --name weather-recent --retention 24h
ID Name Retention Shard group duration Organization ID Schema Type
9f22d3a9777be60e weather-recent 24h0m0s 1h0m0s bf6893ac12376786 implicit
Note the shard group duration quietly changing with the retention: the server stores points in time-sliced groups of files, and chooses the slice to suit how long the data will live. It is the server's business, not yours — but it explains the file layout a backup shows you in chapter 10.
The point that was too old
Into weather-recent, the lab wrote
two points: one from now, and the
same reading stamped three days ago.
An older InfluxDB would have taken both
and quietly dropped the old one. The
2.9 server refuses, loudly, and the
refusal is worth reading whole:
Error: failed to write data: 422 Unprocessable Entity: failure writing points
to database: partial write: dropped 1 points outside retention policy of
duration 24h0m0s - oldest point weather,station=rooftop-1 at
2026-10-29T03:16:53Z dropped because it violates a Retention Policy Lower
Bound at 2026-10-31T03:16:54Z
Three lessons in one error. The write is a partial write: the good point landed, the old one did not, and the command exits 1 — a script that ignores exit codes will silently lose data here while believing the batch succeeded. The bound is stated to the second: in a 24-hour bucket, "too old" is a precise line, not a mood. And the error names the point it dropped. Querying the bucket over seven days returns exactly the one surviving point:
rooftop-1 2026-11-01T03:16:53Z 21.0
The half the lab could not watch
The write-side refusal above is only half of retention. The other half — points that were legal when written growing old and being deleted as their shard groups expire — happens on the server's own schedule, and watching it requires either a day of patience or a bucket whose retention is measured in minutes and data aged to match. This guide states that behaviour from the documentation rather than staging it: retention expiry is real, automatic, and total for the shards it takes. Treat it as a promise with a delay, not an instant: a point can be queryable for a while after its retention birthday, until its shard's turn comes. If a point must be gone now, that is a delete, and chapter 11 performs one.
Sizing a bucket's memory
The practical question — how long should raw data live? — has a household answer: as long as you ask questions of the raw points themselves. "When exactly did the temperature cross 20°?" needs raw data. "What were last month's afternoons like?" needs only the ten-minute means chapter 9 keeps — in a bucket whose retention can be a year, at a tenth of the size. Retention is not housekeeping; it is the design decision that decides what questions remain askable, and when.