Metrics in Apache Cassandra 1.2

By Yuki Morishita -  January 30, 2013 | 1 Comment

Apache Cassandra exposes various kind of internal metrics from client read/write request latencies to ColumnFamily’s Bloom filter false positive ratio through JMX. From version 1.1, Cassandra started using Yammer’s Metrics library to track new client request metrics. Cassandra 1.2 expands use of the library to other metrics that are already available and put them together into org.apache.cassandra.metrics JMX domain. For backward compatibility, metrics are still available through the same JMX location as before (in fact, nodetool is still using old interface), but those implementations are (almost) replaced by new metrics.


So what’s good about using Metrics library? Metrics library offers some fundamental tools for tracking metrics such as Counters, Gauges and Timers with ease of use API.

For example, to track client request read/write latency, we use Timer. You just code to start and stop Timer and it calculates all the interesting metrics we need. As you can see in the picture bellow, write latency now shows various percentiles, min, mean, max values and request rates.

jconsole showing write latency metrics

Exporting metrics

One nice feature that Metrics library has is the ability to export metrics to files or other systems periodically.
There are official “metrics reporters” to export metrics to csv files, console, and external systems like Ganglia and Graphite. Also, there are community developed reporters like statsd reporter.

Example: Graphite integration

Let me show you quick example. Metrics reporting feature is not fully integrated into Cassandra yet (there is a ticket for this), so you need to do some coding to configure reporting.
Since we don’t want to add code to Cassandra itself, we use java agent to setup metrics reporting to Graphite.

1. Get Metrics Graphite reporter jar

You need to grab metrics-graphite-2.0.3.jar and place it to $CASSANDRA_HOME/lib directory. When Cassandra starts up, it is added to classpath automatically. We also use it to compile our agent.

2. Write java code to configure GraphiteReporter

You also need MANIFEST.MF to run as a java agent

3. Package into jar

Compile the code and package into jar file. For example:

$ javac -cp $CASSANDRA_HOME/lib/metrics-core-2.0.3.jar:$CASSANDRA_HOME/lib/metrics-graphite-2.0.3.jar com/datastax/example/
$ jar -cfM reporter.jar .

4. Edit

You need to add following line at the end of “conf/” to load your jar as java agent.

JVM_OPTS="-javaagent:/path/to/your/reporter.jar $JVM_OPTS"

5. Start Cassandra

And voilà. Eventually you can see your Metrics through Graphite web interface.

Graphite web interface showing Cassandra metrics

Available metrics

There is a large number of metrics available in Cassandra so I cannot list all up in this post. Instead, you can find the list of new metrics and their brief explanations at Apache Cassandra Wiki.


In this article, I showed how cassandra’s metrics are built using Yammer’s Metrics library and example reporting using Graphite. New metrics offer much more information than previous versions, and are easily integrated to other systems.


  1. sanjay says:

    Can anyone give me a sample Report agent code.



Your email address will not be published. Required fields are marked *

Subscribe for newsletter:

Tel. +1 (408) 933-3120 Offices France Germany

DataStax Enterprise is powered by the best distribution of Apache Cassandra™.

© 2017 DataStax, All Rights Reserved. DataStax, Titan, and TitanDB are registered trademark of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache Cassandra, Apache, Tomcat, Lucene, Solr, Hadoop, Spark, TinkerPop, and Cassandra are trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.