How to get InfluxDB measurement size?

Viewed 13695

I have a an InfluxDB measurement named kpi. I want to get the size of that single measurement in MB.

So far I have tried:

du -sh /var/lib/influxdb/data/demo/
27M     /var/lib/influxdb/data/demo/

But this command gives me the size of the whole database.

I have also tried this command:

> select count(counter) from kpi

name: kpi
time count
---- -----
0    1479533
>

But this only gives me the entries count.

How can I get the size of this particular measurement?

2 Answers

I have a grafana board that shows me 'filestore' bytes from influx internal stats, like so:

SELECT sum("diskBytes") FROM "_internal".."tsm1_filestore" WHERE time >= now() - 6h GROUP BY time(30s), "database"

This is not the actual size on disk (compared with /var/lib/influxdb/data/), but could give you an indication which database is growing large.

Update:

This ensures to have the latest value of each database which is much more accurate.

SELECT SUM(diskBytes) FROM (
  SELECT max(diskBytes) AS "diskBytes" 
  FROM "influxdb_tsm1_filestore" 
  WHERE $timeFilter AND "database" != 'annotation'
  GROUP BY "database", "id"
)  GROUP BY time($__interval), "database"

The issue here is a Measurement spans multiple shards in its lifetime which makes measuring the size of one rather non-trivial. May I ask why you're looking to do this? Perhaps merely knowing the number of series in this kpi measurement would suffice?

To do this, you would simply use the command: show series cardinality from kpi

Related