Cassandra is one of many Java-based systems that offers metrics via JMX. The JMX Exporter offers way to use these with Prometheus. By following these steps you can be up and running in under a minute!

We’ll start from scratch, first we download and extract the latest Cassandra tarball:

tar -xzf apache-cassandra-*-bin.tar.gz
cd apache-cassandra-*

We’ll also need the JMX exporter java agent, configuration, and to tell Cassandra to use it:

echo 'JVM_OPTS="$JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.1.0.jar=7070:$PWD/cassandra.yml'"' >> conf/

Now we can run Cassandra:

./bin/cassandra &

If you visit http://localhost:7070/metrics you’ll see the metrics.

Metrics alone aren’t very useful, let’s setup a quick Prometheus server:

tar -xzf prometheus-2.0.0.linux-amd64.tar.gz
cd prometheus-*
cat <<'EOF' > prometheus.yml
 scrape_interval: 10s
 evaluation_interval: 10s
 - job_name: 'cassandra'
    - targets:
      - localhost:7070

Wait half a minute to let Prometheus gather data and then you can access the data via the expression browser!

Have you ever wondered what percentage of time a given service or application spends up or down?

read more

Prometheus 2.1.0 is now out, following on from 2.0.0 last month with several fixes and improvements.

read more