How to enable the Prometheus in Cassandra

How to enable the Prometheus in Cassandra

How to Enable Prometheus Mode in Apache Cassandra

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.


1. Overview

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

2. Prerequisites

  • Apache Cassandra is installed and running.
  • Root or sudo access to the Cassandra server.
  • Prometheus JMX Exporter JAR file available on the server.
  • Port 7071 available for exposing metrics.

3. Create JMX Exporter Directory

sudo mkdir -p /opt/jmx_exporter

Copy the JMX Exporter JAR into the directory:

/opt/jmx_exporter/jmx_prometheus_javaagent.jar

4. Create Exporter Configuration File

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.


5. Configure Cassandra JVM

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.


6. Restart Cassandra

sudo systemctl restart cassandra

Verify Cassandra status:

sudo systemctl status cassandra

Expected:

Active: active (running)

7. Verify Metrics Endpoint

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

8. Configure Applications Manager

While creating the Cassandra monitor in Prometheus mode, provide:

FieldValue
HostCassandra Server IP
Port7071
Endpoint/metrics
ProtocolHTTP/HTTPS

9. Validation

  • Cassandra service is running.
  • Port 7071 is listening.
  • Metrics are accessible through the /metrics endpoint.
  • Applications Manager successfully discovers metrics.

10. Troubleshooting

Address Already in Use

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.

Metrics Endpoint Not Accessible

Verify that Cassandra has loaded the javaagent:

ps -ef | grep java

Confirm the javaagent argument appears in the JVM startup parameters.

Cassandra Fails to Start

Review Cassandra logs:

tail -f /var/log/cassandra/system.log

Ensure the JMX Exporter JAR path and YAML configuration path are valid.


Result

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.


                    New to ADSelfService Plus?

                      • Related Articles

                      • How to enable the prometheus in kafka

                        How to Configure Kafka Monitoring Using Prometheus Mode Note: This document explains how to configure Apache Kafka monitoring through Prometheus integration in Applications Manager. 1. Overview of Monitoring Components Kafka Broker: Generates JMX ...
                      • Enable Bundled Prometheus Exporter for ClickHouse DB

                        Overview ClickHouse provides a built-in Prometheus exporter that allows monitoring tools like Prometheus to scrape internal metrics directly from the database. This eliminates the need for any external exporter in modern setups. In the default ...
                      • How to enable the prometheus mode in Couchbase 7.6 Monitor

                        Couchbase 7.6 - Prometheus Monitoring Setup This guide explains how to enable and configure Prometheus monitoring for Couchbase Server 7.6. Note: From Couchbase 7.0 has built-in Prometheus support. No external exporter is required. STEP 1 – Verify ...
                      • How to scape data of rabbitMQ in prometheus server

                        To enable Prometheus metrics in RabbitMQ, we need to enable the Prometheus plugin and expose the metrics endpoint. Here are the steps. 1️⃣ Enable the Prometheus Plugin in RabbitMQ Run this command on the RabbitMQ server: rabbitmq-plugins enable ...
                      • While trying to add a cassandra monitor, why am i getting "Unable to connect to the host / port" error message?

                        Solution: Applications Manager connects to Apache Cassandra via JMX. The "Unable to connect" error typically indicates that the Cassandra JMX port (default: 7199) is unreachable from the Applications Manager server, is bound incorrectly, or requires ...