Wednesday, December 25, 2013

How to Retrieve Cassandra Statistics through MBeans

Cassandra exposes its statistics through MBeans. So we can simply access its MBeans and retrieve those information. There are several ways you can access MBeans  I'll explains them one by one.

1) JConsole

Type 'jconsole' in your console you will get a window like follows.

If your Cassandra server is already up, you will see in Local Process List. Double click on it and you will get following window.

Go to MBeans tab.

Here, you can see several MBeans exposed by Cassandra server. You can expand them and view information about Cassandra server and its data. For example, if you expand org.apache.cassandra.db, you can see ColumnFamilies, where you can view all statistics related to column families in your Cassandra server. And there you can see StorageServices where you can do certain of operations in Cassandra server, such as removeNode, truncate, drain etc. 

For more information about jConsole, visit

2) Java

We can write a simple java client to retrieve those MBean information, and even to do Cassandra cluster operations I mentioned earlier.

Here, serviceURL is the JMX URL of Cassandra server. ColumnFamilyStatsString is the one which tells which MBeans we need to access. Rest is self-explanatory and I'm not going to explain. :)  

No comments:

Post a Comment