Smart Systems for Home

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

Monitor Apache Cassandra with Free Open Source Software

· 5 min read · Home Tech

In this article
  1. Why Monitoring Cassandra Is Different
  2. Core Metrics to Track
  3. The Standard Stack: Prometheus + Grafana
  4. Alternative Open Source Tools
  5. How to Set Up Prometheus and Grafana
  6. Common Pitfalls and How to Avoid Them
  7. Costs and Licensing
  8. Frequently Asked Questions

Yes, you can fully monitor an Apache Cassandra cluster using free, open source software. Tools like Prometheus, Grafana, and the Cassandra Exporter provide comprehensive metrics collection, visualization, and alerting without any licensing costs.

Why Monitoring Cassandra Is Different

Cassandra is a distributed, peer-to-peer database where every node is equal. This means you cannot just monitor a single server; you must track the health of the entire ring, including replication, gossip, and compactions. Unlike a monolithic database, Cassandra's performance depends on the slowest node in a query path, so per-node metrics are essential. A single slow node can drag down the whole cluster, making it critical to watch node-level metrics like heap usage, disk latency, and pending compactions.

Core Metrics to Track

Before choosing tools, understand what to monitor. The key metrics fall into several categories:

  • Cluster Health: Node status (up/down), load balancing, and token ownership.
  • Latency: Read and write latency percentiles (p50, p99) per table and per node.
  • Throughput: Requests per second, both reads and writes.
  • Compactions: Pending compaction tasks, which can block writes if they pile up.
  • Garbage Collection: GC pause times and frequency—Cassandra is Java-based, so long pauses cause timeouts.
  • Disk and Memory: Disk usage per node, heap usage, and off-heap memory.
  • Replication: Hinted handoff queue size, which grows when nodes are down.

Tools like Prometheus can scrape these metrics directly from each node using an exporter, giving you a real-time view of the entire cluster.

The Standard Stack: Prometheus + Grafana

The most common open source solution is a combination of:

  • Prometheus: A time-series database that scrapes metrics via HTTP endpoints.
  • cassandra-exporter: A Java agent that runs alongside Cassandra and exposes metrics in Prometheus format. It is available on GitHub and is widely used.
  • Grafana: A visualization tool that queries Prometheus and displays dashboards. There are pre-built Cassandra dashboards you can import.

This stack is completely free and self-hosted. You install the exporter on each Cassandra node, configure Prometheus to scrape those endpoints, and then point Grafana at Prometheus. The setup is straightforward and well-documented.

Alternative Open Source Tools

While Prometheus and Grafana are the most popular, other open source options exist:

  • Netdata: A lightweight monitoring agent that provides real-time dashboards with minimal setup. It has a Cassandra plugin that collects metrics via JMX.
  • Zabbix: A full-featured monitoring solution with a Cassandra template. It offers alerting and graphing but is heavier to manage.
  • InfluxDB + Telegraf: Telegraf has a Cassandra input plugin that uses JMX to collect metrics, and InfluxDB stores them. You can visualize with Grafana.
  • Datadog (not open source): For comparison, Datadog offers a commercial agent, but it is not free.

Each tool has its strengths. Netdata is great for quick, out-of-the-box visibility, while Zabbix is better for organizations already using it for other infrastructure.

How to Set Up Prometheus and Grafana

Here is a high-level guide to get you started:

  1. Install the exporter: Download the cassandra-exporter JAR and place it in the lib directory of your Cassandra installation. Restart Cassandra.
  2. Configure Prometheus: Add a scrape job in prometheus.yml that targets each node's exporter port (default 8080). Use a service discovery mechanism if you have many nodes.
  3. Start Prometheus: Run Prometheus as a service or container, and verify it is scraping metrics by checking the targets page.
  4. Set up Grafana: Install Grafana, add Prometheus as a data source, and import a Cassandra dashboard (for example, from Grafana's community dashboards).
  5. Create alerts: Use Grafana's alerting rules to notify you when metrics exceed thresholds, such as heap usage above 80% or pending compactions above 10.

This setup gives you a complete monitoring solution in under an hour, with no licensing fees.

Common Pitfalls and How to Avoid Them

Monitoring Cassandra has several traps that can lead to false alarms or missed issues:

  • JMX metrics vs. native metrics: The exporter uses JMX, which can add overhead. Use it carefully in production, and consider using Cassandra's built-in metrics via the Dropwizard reporter.
  • Metric aggregation: Aggregating metrics across nodes hides problems. Always view per-node metrics to spot a slow node.
  • GC pauses: Long GC pauses are a leading cause of timeouts. Monitor the GC logs and set alerts for pauses over 200ms.
  • Disk space: Cassandra needs free disk for compactions. Monitor disk usage per node and set alerts at 70%.
  • Network issues: Use tools like iperf to test network throughput between nodes, as network latency directly affects query performance.

Costs and Licensing

The tools mentioned are truly free and open source, with no hidden costs. Prometheus, Grafana, Netdata, and Zabbix are all under open source licenses (Apache 2.0, AGPL, GPL, etc.). You only pay for the hardware to run them and the time to maintain them. This is a major advantage over commercial solutions like Datadog or New Relic, which charge per node and can become expensive as your cluster grows.

Frequently Asked Questions

Can I monitor Cassandra without JMX?

Yes, Cassandra exposes metrics via its own metrics system (Dropwizard) that can be configured to send data to Graphite, Prometheus, or other backends. The cassandra-exporter uses JMX under the hood, but you can also use the built-in metrics reporter to push to a monitoring system directly.

Is Prometheus suitable for large clusters?

Yes, Prometheus is designed for high cardinality and can handle thousands of nodes. However, you may need to use federation or thanos for long-term storage if you retain data for months.

Do I need to monitor every node individually?

Yes, because Cassandra is distributed, a single node failure can affect the entire cluster. Always monitor each node's health, latency, and storage.

What is the best way to alert on Cassandra issues?

Use Grafana alerts or Prometheus alertmanager. Set alerts for node down, high heap usage, pending compactions, and high latency percentiles. Avoid alerting on every metric to prevent alert fatigue.

Can I use the same tools for other databases?

Yes, Prometheus and Grafana support many databases and systems, so you can use the same stack for PostgreSQL, MySQL, or even infrastructure monitoring. This reduces tool sprawl.