Recently I\'ve started working on Grails integration with Cassandra using the Java driver for cassandra(cassandra-driver-core-2.0.2). So I was curious to know how we can find ou
To get statistics regarding column families in Cassandra, you can simply run the command:
nodetool cfstats
It reports statistics about tables which include the live data size as well as on disk.
The documentation about this utility for Cassandra 2.1 is available here.
You can use both the command below based on old and new version of Cassandra.
nodetool cfstats or nodetool tablestats
Above command will give you size details about keyspace and table. Also you can refer below link to get more ddetails about how to use with different options https://docs.datastax.com/en/dse/6.7/dse-dev/datastax_enterprise/tools/nodetool/toolsTablestats.html
To get the statistics regarding column families in Cassandra with respect to keyspaces or tables, you can simply run the below command:
nodetool cfstats
Result: This will return the complete statistics related to available keyspaces.
But, in case you want to find out the statistics of specific keyspaces or tables, run below command:
For Keyspace(s) :
nodetool cfstats <keyspace_name>
OR
nodetool cfstats -H <keyspace_name>
For Table(s) :
nodetool tablestats <keyspace_name>.<table_name>
OR
nodetool tablestats -H <keyspace_name>.<table_name>
Note: -H denotes Human Readable format
For more details please refer, nodetool cfstats
Findings:
You might see SSTable count
as 0
Space used (live)
and Space used (total)
as 0 bytes
To know WHY(s) of the above two findings please refer: Reason of why SSTable count shown as 0
I've created a small script to print nodetool
results in a nice table:
#!/bin/sh
nodetool cfstats -H | awk -F ' *: *' '
BEGIN { print "Keyspace,Table,Live,Total" }
/^Keyspace : / { ks = $2 }
/\tTable:/ { t = $2 }
/\tSpace used .live/ { sp = $2 }
/\tSpace used .total/ { print ks "," t "," sp "," $2 }
' | column -s , -t