How-to
How to measure InfluxDB 2 OSS bucket disk usage
Short answer
InfluxDB 2 OSS cannot report a bucket's disk usage through Flux: the usage.from() function queries InfluxDB Cloud organizations only. Resolve the bucket name to its ID with influx bucket list, confirm the instance's engine data path, then run du against the directory named for that ID. The same path feeds Telegraf's inputs.filecount plugin for continuous tracking.

On this page
- Can Flux tell you the size of an InfluxDB 2 OSS bucket?
- How do you find the bucket ID behind a bucket name?
- Where does InfluxDB 2 OSS store a bucket on disk?
- What command measures one bucket's disk usage?
- Why does du not match the number of points you wrote?
- How do you track bucket disk usage over time?
- How do you prove a write changed the bucket directory?
- Questions asked
InfluxDB 2 OSS cannot tell you how much disk one bucket uses: Flux on OSS has no bucket-size function, and the usage.from function queries InfluxDB Cloud organizations only. The reliable measurement lives one layer down, at the filesystem. Resolve the bucket name to its ID with influx bucket list, find the directory named for that ID under the instance's engine data tree, and run du against it — du -sh for one bucket, du --max-depth=1 on the parent directory for every bucket at once. This article gives the commands, the arithmetic that turns four directory readings into a capacity decision, and a Telegraf inputs.filecount setup that keeps the figure current without anyone typing the command again.
Can Flux tell you the size of an InfluxDB 2 OSS bucket? #
No — Flux on an OSS instance has no function that returns a bucket's disk usage; the usage.from function is documented to return usage data from an InfluxDB Cloud organization, so on OSS the size lives at the filesystem, not in a query result.
Flux operates on the stored time-series records: it can filter, window and aggregate them, but it never inspects the host filesystem where the database process keeps its files, and OSS has no usage service standing next to the engine that a query could ask. The working procedure is short:
- Confirm the target is OSS — the reported case ran the Docker image
influxdb:2.0.7; Cloud answers this question with its usage tooling instead. - Resolve the bucket name to its ID with
sudo -u influxdb influx bucket list, run where the CLI is configured for the right organization. - Locate the active engine data directory and confirm it contains a child directory named exactly for that ID.
- Measure every bucket at once with
du --max-depth=1 -h /var/lib/influxdb/engine/data, or one bucket withdu -shagainst its ID directory. - Keep the figure current by pointing the Telegraf
[[inputs.filecount]]plugin at the same directory, as set up further down.
How do you find the bucket ID behind a bucket name? #
Run influx bucket list and read the ID column: the on-disk directory is named for that ID, never for the bucket name, so a bucket called TelemetryData lives in a 16-character hexadecimal directory that only the CLI reliably gives you.
sudo -u influxdb influx bucket list prints one row per bucket with the ID first. One reported installation showed:
| ID | Name | Retention |
|---|---|---|
| ac0875d38424582f | _monitoring | 168h0m0s |
| f92231ce585d2e6c | _tasks | 72h0m0s |
| 686d3c919b5f28d1 | default | 672h0m0s |
| 9e5b8ddca4fd19e8 | default_downsampled | 8760h0m0s |
The listing also carries the organization ID; note it together with the retention so that near-identical names — default and default_downsampled differ by one word — cannot steer the measurement to the wrong directory. The browser view has a scale limit here: installations with more than 100 buckets have reported that the UI's Load Data > Buckets page stops at 100 entries, so take IDs from the CLI once the estate grows past what the browser shows.
Where does InfluxDB 2 OSS store a bucket on disk? #
Under the instance's engine data directory, in a subdirectory whose name is exactly the bucket ID; on the reported influxdb:2.0.7 container that parent was /var/lib/influxdb/engine/data, but the real location is whatever your volume mapping or service configuration defines.
The path is a property of the installation, not of InfluxDB itself. Packaged installs usually keep the engine under /var/lib/influxdb, containers move it wherever the volume mapping says, and one command in the reported thread pointed at /var/influxdb/engine/data instead — two installations, two parents — while user-level setups keep the tree under the service account's home. Three checks gate the measurement: the engine data parent belongs to the live instance and not to a leftover volume, backup copy or test container; a child directory matches the bucket ID character for character; and the account running du can traverse to it. Pass all three and everything du reports next belongs to that bucket and nothing else.
What command measures one bucket's disk usage? #
Run du against the bucket ID directory: du -sh /var/lib/influxdb/engine/data/686d3c919b5f28d1/ prints one human-readable figure for that bucket, and du --max-depth=1 -h on the parent tree prints every bucket's figure side by side.
Run it under an account that can enter and read the directory: a permission error is not a zero-size answer, and du exits nonzero when it cannot descend. Save the path, the timestamp and the output together so the next reading compares like with like. Worked example from the reported installation, whole tree first:
du --max-depth=1 -h /var/lib/influxdb/engine/data
156K /var/lib/influxdb/engine/data/ac0875d38424582f
3.7G /var/lib/influxdb/engine/data/686d3c919b5f28d1
384K /var/lib/influxdb/engine/data/f92231ce585d2e6c
210M /var/lib/influxdb/engine/data/9e5b8ddca4fd19e8
On GNU du the suffixes are binary units, so G means GiB. Adding the tree: 210 MiB / 1024 = about 0.21 GiB, and the two system buckets hold 156 KiB + 384 KiB = 540 KiB, under 0.6 MiB together and negligible at gibibyte scale. The whole engine sits near 3.7 + 0.21 = about 3.9 GiB. The decision follows: the default bucket owns 3.7 of those 3.9 GiB, roughly 95 percent, so capacity work on this instance — retention changes, cardinality cuts, downsampling — targets the default bucket, while the two system buckets together hold under one percent. These readings belong to one reported installation and are an example, not sizing limits; rerun the same command on your own tree before acting on a share that differs.
Why does du not match the number of points you wrote? #
Because the directory holds the persisted database files — shard and index structures with filesystem block allocation — not a plain dump of the values, so its byte total tracks storage structures and allocation rounding, while a query counts points, and the two numbers answer different questions.
That is the engine working as designed: points are packed into shard files, expired data lingers until the engine reclaims the space, and a small write can occupy more disk than the raw bytes of its values. Retention stretches the gap the other way — a long-retention bucket does not hold its full window of bytes on day one, and the directory grows toward that ceiling as data arrives and expires. Match the measurement to the question:
| The question | Measure with | Not with |
|---|---|---|
| How much disk does this bucket consume here? | du on the bucket ID directory | any Flux query on OSS |
| Which directory belongs to which bucket? | the ID column of influx bucket list | the bucket name used as a path |
| How much usage has a Cloud org recorded? | Cloud usage tooling with usage.from | du on an OSS path |
| What does one sensor cost on disk? | per-point disk arithmetic | the bucket directory total |
What one sensor costs is its own calculation: What one Telegraf point really costs on InfluxDB disk works the per-point math, and the directory totals here are its complement, not the same number. When the sum of the ID directories starts crowding the volume, the decision moves up a level to the host — Sizing one PC for InfluxDB, Telegraf, Grafana and Node-RED works through that side.
How do you track bucket disk usage over time? #
Point the Telegraf inputs.filecount plugin at the bucket ID directory and it reports the file count and size of that directory on every collection interval, which turns the one-off du figure into a trend line inside the InfluxDB you already run.
[[inputs.filecount]]
directory = "/var/lib/influxdb/engine/data/686d3c919b5f28d1"
Four rules keep the series honest:
- Resolve the ID again before trusting a long-lived config: delete and recreate a bucket and the engine assigns a new ID, leaving the collector pointed at a dead directory.
- Give the Telegraf account permission to traverse and list that path and nothing beyond it — the collector needs directory metadata, not the contents of the database files.
- Validate once against a contemporaneous du on the same path; if the two disagree, look for symbolic links, a different mount, or a scope that sweeps in neighboring buckets.
- Without Telegraf, schedule the same du command from the operating system's own scheduler and store the timestamped output — same path, same command, same units, comparable history.
Per-bucket readings only stay meaningful while each bucket holds its own stream. If your MQTT payload is being fanned out into every bucket, each ID directory carries its own copy and every reading double-counts — Why does Telegraf send MQTT data to every InfluxDB bucket explains the cause and the fix. To split streams on purpose, one bucket per data source, Configuring Telegraf bucket_tag Routing to InfluxDB v2 Buckets shows the bucket_tag setup.
How do you prove a write changed the bucket directory? #
Write a controlled batch through your normal ingestion path, query it back from the named bucket, then repeat the identical du command and compare against a saved earlier reading taken at the same path with the same units.
The human-readable figure hides small writes: du -h rounds to one decimal of the largest unit, so a 40 MiB test batch onto a bucket reading 3.7G lands at 3.74G and still prints 3.7G. Measure in kibibytes instead — du -sk prints an integer, and 40 MiB is 40,960 KiB (40 times 1024) that the next reading must show. The check passes when three things hold at once: the query returns the controlled batch from the named bucket, influx bucket list still maps that name to the measured ID, and the kibibyte count on the ID directory has grown by at least the batch's contribution. If the reading does not move, the write reached a different instance or a different volume than the one measured — reconcile the volume mapping, then repeat.
One warning belongs here: never reclaim disk by deleting files inside a bucket ID directory. The engine expects those files, and hand deletion corrupts the bucket; lower the bucket's retention or delete the bucket through the CLI and let the engine remove its own files.
Questions asked
Does anything change on InfluxDB Cloud?
Yes — usage is recorded server-side. The usage.from() Flux function returns usage data from an InfluxDB Cloud organization, and the Cloud usage dashboard graphs storage per bucket, so no filesystem step applies. A Cloud organization has no engine data directory you can reach, so keep du and the inputs.filecount collector out of Cloud questions entirely.
The instance runs in Docker — where do I run the measurement?
Either inside the container or on the host path the container's volume maps to; both must describe the same storage. The reported installations even disagreed with each other — one showed /var/lib/influxdb/engine/data, another /var/influxdb/engine/data — so read the volume mapping in the container or service definition instead of copying either path. A host command against a directory the container never mounts measures the wrong bytes.
How do I cap a bucket's disk usage before it fills the disk?
Multiply measured growth by the retention window. For example, a bucket adding 100 MiB per day with the 672h0m0s retention of the reported default bucket levels off near 2800 MiB — 100 MiB for each of 28 days — about 2.8 GiB, while the same arrival into the 8760h0m0s bucket spans 365 days and settles near 36,500 MiB, roughly 36 GiB. Substitute your own daily growth, taken from two du readings a day apart.
Why does the bucket listing run as the influxdb user?
The CLI reads its token and organization from the configuration of the account that set it up, and on a packaged install that account is usually the influxdb service user — hence sudo -u influxdb influx bucket list in the reported commands. If you run the CLI under your own account without that configuration, it has no token to present; borrow the service account's context or pass the token and organization explicitly.


