Cassandra
Monitor Apache Cassandra metrics with OpenTelemetry and Last9
Use OpenTelemetry to monitor your Apache Cassandra cluster and send telemetry data to Last9. This integration runs the opentelemetry-jmx-metrics JAR as a service alongside Cassandra to collect JMX metrics, which are forwarded to the OTel Collector via OTLP.
Read the sample configuration for more details.
Prerequisites
- Apache Cassandra 3.x or 4.x installed and running
- Java 11+ installed on the host (required by the JMX metrics JAR)
- JMX enabled in Cassandra (enabled by default on port 7199)
- Last9 account with integration credentials
Verify JMX Access
Cassandra enables JMX on port 7199 by default. Verify it is reachable:
ss -tlnp | grep 7199Install OpenTelemetry Collector
sudo apt-get update && sudo apt-get install -y wgetwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.144.0/otelcol-contrib_0.144.0_linux_amd64.debsudo dpkg -i otelcol-contrib_0.144.0_linux_amd64.debsudo apt-get update && sudo apt-get install -y wgetwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.144.0/otelcol-contrib_0.144.0_linux_arm64.debsudo dpkg -i otelcol-contrib_0.144.0_linux_arm64.debwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.144.0/otelcol-contrib_0.144.0_linux_amd64.rpmsudo rpm -ivh otelcol-contrib_0.144.0_linux_amd64.rpmDownload JMX Metrics JAR
The JMX receiver requires a metrics collection JAR:
sudo mkdir -p /optsudo wget -O /opt/opentelemetry-jmx-metrics.jar \ https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/v1.43.0/opentelemetry-jmx-metrics.jarConfigure JMX Metrics Collection
-
Create the JMX config
Create
/etc/otelcol-contrib/jmx-config.properties:otel.exporter.otlp.endpoint = http://localhost:4317otel.jmx.interval.milliseconds = 60000otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmiotel.jmx.target.system = cassandraotel.metrics.exporter = otlpIf JMX authentication is enabled, add:
otel.jmx.username = <jmx_username>otel.jmx.password = <jmx_password> -
Run the JMX metrics JAR as a service
Create
/etc/systemd/system/cassandra-jmx-metrics.service:[Unit]Description=Cassandra JMX Metrics CollectorAfter=cassandra.service[Service]ExecStart=java -jar /opt/opentelemetry-jmx-metrics.jar -config /etc/otelcol-contrib/jmx-config.propertiesRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.targetsudo systemctl daemon-reloadsudo systemctl enable --now cassandra-jmx-metrics -
Create the Collector Configuration
Create
/etc/otelcol-contrib/config.yaml:receivers:otlp:protocols:grpc:endpoint: 0.0.0.0:4317hostmetrics:collection_interval: 60sscrapers:cpu:metrics:system.cpu.logical.count:enabled: truememory:metrics:system.memory.utilization:enabled: truesystem.memory.limit:enabled: trueload:disk:filesystem:metrics:system.filesystem.utilization:enabled: truenetwork:paging:processors:batch:timeout: 5ssend_batch_size: 10000send_batch_max_size: 10000resourcedetection/system:detectors: ["system"]system:hostname_sources: ["os"]transform/add_db_system:metric_statements:- context: datapointstatements:- set(attributes["host.name"], resource.attributes["host.name"])- set(attributes["db.system"], "cassandra")exporters:otlp/last9:endpoint: "{{ .Logs.WriteURL }}"headers:"Authorization": "{{ .Logs.AuthValue }}"service:pipelines:metrics/jmx:receivers: [otlp]processors: [batch, transform/add_db_system]exporters: [otlp/last9]metrics/host:receivers: [hostmetrics]processors: [batch, resourcedetection/system, transform/add_db_system]exporters: [otlp/last9]Replace
endpointandAuthorizationwith your Last9 credentials from the Integrations page. -
Start the Collector
sudo systemctl enable --now otelcol-contrib
Nodetool Metrics (Extended Collection)
JMX covers per-table latency and request counts, but some cluster-level metrics are only accessible via nodetool. The integration includes a nodetool exporter that runs alongside Cassandra and exposes these additional metrics on port 9500.
Bare-metal setup — create /etc/systemd/system/cassandra-nodetool-exporter.service:
[Unit]Description=Cassandra Nodetool Prometheus ExporterAfter=cassandra.service
[Service]Environment=CASSANDRA_HOST=localhostEnvironment=CASSANDRA_JMX_PORT=7199Environment=EXPORTER_PORT=9500ExecStart=python3 /opt/nodetool-exporter.pyRestart=alwaysRestartSec=15
[Install]WantedBy=multi-user.targetDownload the exporter script:
sudo wget -O /opt/nodetool-exporter.py \ https://raw.githubusercontent.com/last9/opentelemetry-examples/main/otel-collector/cassandra/nodetool-exporter.pysudo systemctl daemon-reload && sudo systemctl enable --now cassandra-nodetool-exporterAdd the following receiver and pipeline to your OTel Collector config:
receivers: prometheus/nodetool: config: scrape_configs: - job_name: cassandra_nodetool scrape_interval: 60s static_configs: - targets: ["localhost:9500"]
service: pipelines: metrics/nodetool: receivers: [prometheus/nodetool] processors: [batch, transform/add_db_system] exporters: [otlp/last9]Metrics Collected
| Metric category | Examples |
|---|---|
| Read/write latency | cassandra_client_request_read_latency_50p_microseconds, cassandra_client_request_write_latency_99p_microseconds |
| Request counts | cassandra_client_request_count_total, cassandra_client_request_error_count_total |
| Compaction | cassandra_compaction_tasks_completed_total, cassandra_compaction_tasks_pending |
| Storage | cassandra_storage_load_count_bytes, cassandra_storage_hints_count_total |
| Cluster topology | cassandra_nodetool_nodes_up, cassandra_nodetool_nodes_down |
| Thread pools | cassandra_nodetool_thread_pool_pending, cassandra_nodetool_thread_pool_blocked |
| Heap & cache | cassandra_nodetool_heap_used_mb, cassandra_nodetool_key_cache_hit_rate |
| System | CPU, memory, disk, network via hostmetrics |
Verification
-
Check Collector Status
sudo systemctl status otelcol-contrib -
View Collector Logs
sudo journalctl -u otelcol-contrib -f -
Verify Metrics in Last9
Log into your Last9 account and check that Cassandra metrics are being received. Look for metric names starting with
cassandra..
Troubleshooting
-
JMX connection refused
# Verify JMX port is listeningss -tlnp | grep 7199# Check Cassandra is runningnodetool status# Test JMX connectivityjava -jar /opt/opentelemetry-jmx-metrics.jar \-targetSystem cassandra \-endpoint service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi -
ClassNotFoundExceptionor JAR issues# Verify Java is installedjava -version# Check JAR is present and readablels -la /opt/opentelemetry-jmx-metrics.jar -
Collector not starting
sudo journalctl -u otelcol-contrib -n 100 --no-pager
Please get in touch with us on Discord or Email if you have any questions.