Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Monitor Cassandra Cluster Performance with Open Source

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide shows you how to monitor a Cassandra cluster using open-source tools on Linux. You'll track key metrics like read/write latency, compaction activity, and node health, and set up alerts so you catch problems before they affect users. By the end, you'll have a working monitoring stack with Prometheus, Grafana, and the Cassandra exporter, plus a few command-line checks for quick troubleshooting.

What You'll Need

  • A Linux server (Ubuntu 20.04+, Debian 11+, or CentOS 7+) with sudo access
  • An existing Cassandra cluster (at least one node) running version 3.x or 4.x
  • Java 8 or 11 installed on the monitoring server (for the exporter)
  • Network access from the monitoring server to each Cassandra node's JMX port (default 7199) and the exporter port (default 7070)
  • Basic familiarity with the command line and editing config files

Step-by-Step

  1. Install Prometheus on the monitoring server. Download the latest release from the official Prometheus site, extract it, and move the binary to /usr/local/bin. Create a systemd service file so it starts on boot. Test with prometheus --version.
  2. Install the Cassandra exporter. Use the cassandra-exporter project (a JMX exporter for Cassandra). Download the JAR file and place it in a directory like /opt/cassandra-exporter. Create a systemd service for it, pointing to the JAR. The exporter runs on port 7070 by default.
  3. Configure the exporter to connect to your Cassandra node. The exporter needs to know the JMX port and credentials. Edit the exporter's config file (usually config.yml) to set the host and port. If you have authentication enabled in Cassandra, add the JMX username/password. Restart the service.
  4. Test the exporter endpoint. On the monitoring server, run curl http://localhost:7070/metrics. You should see a large list of metrics like cassandra_clientrequest_read_latency and cassandra_storage_load. If not, check the exporter logs.
  5. Add Cassandra nodes to Prometheus. Edit prometheus.yml and add a scrape job for each node. Example:
    scrape_configs:
      - job_name: 'cassandra'
        static_configs:
          - targets: ['node1:7070', 'node2:7070', 'node3:7070']
    Replace with your actual node IPs or hostnames. Restart Prometheus.
  6. Install Grafana. Add the official Grafana repository, install the package, and start the service. Access the web UI at http://your-server:3000 with default admin/admin.
  7. Add Prometheus as a data source in Grafana. Go to Configuration → Data Sources → Add data source, choose Prometheus, and set the URL to http://localhost:9090. Click Save & Test.
  8. Import a Cassandra dashboard. In Grafana, go to Dashboards → Import, enter dashboard ID 10485 (a popular community dashboard for Cassandra), and select your Prometheus data source. You'll see graphs for latency, throughput, compactions, and more.
  9. Set up alerts for critical metrics. In Grafana, create alert rules for high read/write latency (e.g., p99 > 50ms), high CPU usage, or node down. Use the Alerting section to configure notification channels like email or Slack.
  10. Add the other Cassandra nodes. Repeat steps 3-4 on each node, or install the exporter on each and add them to Prometheus. For a cluster, you'll want every node monitored.
  11. Verify with nodetool. For quick checks, use nodetool status to see node state, nodetool tpstats for thread pool activity, and nodetool compactionstats for compaction progress. These are essential for day-to-day troubleshooting.

Common Mistakes

  • Not opening the firewall – Prometheus can't scrape if ports 7070 and 9090 are blocked. Open them in your firewall config.
  • Using the wrong JMX port – Cassandra's JMX port is 7199 by default, but some setups use 8080 or a custom port. Check cassandra-env.sh for JMX_PORT.
  • Forgetting JMX authentication – If you have enabled JMX auth, the exporter will fail silently. Configure the exporter with the correct credentials.
  • Scraping too frequently – Setting scrape_interval to 1s can overload the exporter and Cassandra. Use 15s or 30s.
  • Not monitoring all nodes – A single node's metrics don't represent the cluster. Add every node to Prometheus.

Tips

  • Use the cassandra-exporter with the --config flag to specify your config file explicitly.
  • Set up a separate Prometheus retention policy (e.g., 15 days) to balance storage and history.
  • Create a Grafana alert for up == 0 on the exporter job to know when a node is down.
  • Use nodetool status regularly to check for unbalanced tokens or nodes in UN (Up Normal) state.
  • For production, consider using the official DataStax metrics collector, but the open-source stack here is sufficient for most needs.

Troubleshooting

Exporter shows no metrics or connection refused: Check that the exporter is running (systemctl status cassandra-exporter) and that the JMX port is reachable from the exporter's host. Try telnet localhost 7199 on the Cassandra node.

Prometheus target shows 'DOWN': Verify the exporter URL is correct and that Prometheus can reach it. Use curl http://node:7070/metrics from the Prometheus server. If it fails, check firewall rules and SELinux (on CentOS).

Grafana dashboard shows 'No data': Ensure the data source is correctly configured and that the dashboard's variables match your Prometheus job name. Try running a query in the Explore tab, e.g., cassandra_clientrequest_read_latency.

Metrics appear but are all zeros: The exporter may be connecting to the wrong Cassandra node or the metrics names have changed. Check the exporter logs for errors. Also, some metrics only appear after queries are run.

High CPU usage from the exporter: Reduce the scrape interval or increase the JMX connection timeout. Also, ensure you're not running multiple exporters on the same node.

Frequently Asked Questions

Can I use this stack for Cassandra 4.x?

Yes, the exporter and Prometheus work with Cassandra 4.x. Just ensure you have Java 11 installed and that JMX is configured correctly.

Do I need to install the exporter on every node?

Yes, to get cluster-wide metrics, install the exporter on each node. Alternatively, you can run one exporter per node, but not one for the whole cluster.

What are the most important metrics to watch?

Watch cassandra_clientrequest_read_latency and write latency (p99), cassandra_storage_load, cassandra_compaction_tasks_pending, and cassandra_threadpools for blocked threads.

How do I add a new node to monitoring?

Install the exporter on the new node, add its IP to the Prometheus scrape config, and restart Prometheus. Grafana will pick it up automatically.

Can I monitor Cassandra without JMX?

Yes, you can use the cassandra-metrics via the Dropwizard metrics reporter, but JMX is the standard and easiest way with the exporter.

Is there a way to see historical data?

Prometheus stores data with a retention period (default 15 days). For longer history, you can increase retention or use Thanos or VictoriaMetrics.