This article explains how to configure Apache Cassandra to expose metrics in Prometheus format using JMX Exporter. Once configured, Applications Manager can collect Cassandra metrics using Prometheus mode.
Apache Cassandra exposes runtime metrics through Java Management Extensions (JMX). To make these metrics available in Prometheus format, the Prometheus JMX Exporter must be configured as a Java Agent within the Cassandra JVM.
After configuration, Cassandra metrics will be available through an HTTP endpoint:
http://<Hostname>:7071/metrics
sudo mkdir -p /opt/jmx_exporter
Copy the JMX Exporter JAR into the directory:
/opt/jmx_exporter/jmx_prometheus_javaagent.jar
Create the configuration file:
sudo vi /opt/jmx_exporter/cassandra.yml
Add the following configuration:
startDelaySeconds: 0
ssl: false
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: ".*"
This configuration exports all available Cassandra JMX metrics.
Edit the Cassandra environment configuration file:
sudo vi /etc/cassandra/cassandra-env.sh
Add the following line at the end of the file:
JVM_OPTS="$JVM_OPTS -javaagent:/opt/jmx_exporter/jmx_prometheus_javaagent.jar=7071:/opt/jmx_exporter/cassandra.yml"
This configuration instructs Cassandra to load the JMX Exporter and expose metrics through port 7071.
sudo systemctl restart cassandra
Verify Cassandra status:
sudo systemctl status cassandra
Expected:
Active: active (running)
Verify that the exporter is listening on port 7071:
sudo ss -ltnp | grep 7071
Access the metrics endpoint:
curl http://<hostname>:7071/metrics
Successful output should display Prometheus-formatted metrics similar to:
# HELP jvm_memory_bytes_used
# TYPE jvm_memory_bytes_used gauge
# HELP cassandra_storage_load
# TYPE cassandra_storage_load gauge
While creating the Cassandra monitor in Prometheus mode, provide:
| Field | Value |
|---|---|
| Host | Cassandra Server IP |
| Port | 7071 |
| Endpoint | /metrics |
| Protocol | HTTP/HTTPS |
Error:
java.net.BindException: Address already in use
The configured exporter port is already occupied by another process. Use a different port in the javaagent configuration and restart Cassandra.
Verify that Cassandra has loaded the javaagent:
ps -ef | grep java
Confirm the javaagent argument appears in the JVM startup parameters.
Review Cassandra logs:
tail -f /var/log/cassandra/system.log
Ensure the JMX Exporter JAR path and YAML configuration path are valid.
Apache Cassandra is now configured to expose metrics in Prometheus format through the JMX Exporter endpoint, enabling Applications Manager to monitor Cassandra using Prometheus mode.