I have two databases in InfluxDB:
Database #1 = the internal influxdb database (named _internal
by default)
Database #2 = data inserted by Telegraf (called telegraf
).
I am simply trying to monitor the size of the /data/
and /wal/
directories on the disk.
I obtain these readings in two different ways, but they do not agree with each other:
-
Using diskBytes field from the influxdb_shard metric of the InfluxDB Input Plugin in Telegraf, described here, and as recommended in the docs.
-
Using a small bash script to grab the sizes of the
/data/
and/wal/
directories using thedu
command, and executing it with the exec input plugin of Telegraf. Here is the script:
echo "["
du -s -B1 "$@" | awk '{if (NR!=1) {printf ",\n"};printf " { \"dir_size_bytes\": "$1", \"path\": \""$2"\" }";}'
echo
echo "]"
Now, as far as I understand, the influxdb_shard metric gives the sum of both the /wal/ and /data/ directories, and gives a value for each database (which it uses for a Tag). Whereas the result of du will sum data for both both databases and wal for both databases (because they both sit in one directory).
Therefore, to just get the total disk space used, I plot in Grafana the sum of the two shard readings and the sum of the
du /data/
+du /wal/
influxdb_shard
(for database_internal
) +influxdb_shard
(for databasetelegraf
)
Why don’t these two things agree with each other?