|
| 1 | +--- |
| 2 | +title: Cassandra Metrics and Logs Integration Guide |
| 3 | +description: This guide explains how to monitor Apache Cassandra by collecting metrics via the OpenTelemetry JMX receiver and logs via file-based collection, and forward them to OpenObserve for visualization and analysis. |
| 4 | +--- |
| 5 | + |
| 6 | +# Integration with Cassandra Metrics and Logs |
| 7 | + |
| 8 | +This guide provides step-by-step instructions to collect and monitor Apache Cassandra metrics and logs using **OpenTelemetry Collector Contrib** and forward them to OpenObserve. |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +Apache Cassandra is a highly scalable, distributed NoSQL database designed for applications that demand high availability and low-latency read/write operations. |
| 13 | + |
| 14 | +To effectively monitor Cassandra, we will set up OpenTelemetry (OTel) to collect both metrics and logs. OpenTelemetry’s JMX receiver helps gather JVM and Cassandra-specific metrics, while file-based log collection ensures log visibility. The collected logs and metrics will then be forwarded to Openobserve. |
| 15 | + |
| 16 | + |
| 17 | +## Steps to Integrate |
| 18 | + |
| 19 | +??? "Prerequisites" |
| 20 | + - Running **Apache Cassandra** instance(s) |
| 21 | + - OpenObserve account ([Cloud](https://cloud.openobserve.ai/web/) or [Self-Hosted](../../../quickstart/#self-hosted-installation)) |
| 22 | + |
| 23 | +??? "Step 1: Download OpenTelemetry JMX Metrics JAR" |
| 24 | + |
| 25 | + 1. The JMX receiver is used to gather Cassandra and JVM metrics. Install it using the command: |
| 26 | + |
| 27 | + ```bash |
| 28 | + wget https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/v1.32.0/opentelemetry-jmx-metrics.jar -O /opt/opentelemetry-java-contrib-jmx-metrics.jar |
| 29 | + ``` |
| 30 | + |
| 31 | +??? "Step 2: Configure JMX Remote Access in Cassandra" |
| 32 | + |
| 33 | + 1. Edit `/etc/cassandra/cassandra-env.sh` and add: |
| 34 | + ```bash |
| 35 | + JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=9000" |
| 36 | + JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=9000" |
| 37 | + JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" |
| 38 | + JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false" |
| 39 | + ``` |
| 40 | + |
| 41 | + 2. Restart Cassandra: |
| 42 | + ```bash |
| 43 | + systemctl restart cassandra |
| 44 | + ``` |
| 45 | + > Note: The file location may vary depending on your system. |
| 46 | + |
| 47 | +??? "Step 3: Configure the OpenTelemetry Collector" |
| 48 | + |
| 49 | + 1. Create or update `/etc/otel-collector-config.yaml`: |
| 50 | + |
| 51 | + ```yaml |
| 52 | + receivers: |
| 53 | + jmx: |
| 54 | + jar_path: /opt/opentelemetry-java-contrib-jmx-metrics.jar |
| 55 | + endpoint: localhost:9000 |
| 56 | + target_system: cassandra,jvm |
| 57 | + collection_interval: 60s |
| 58 | + |
| 59 | + filelog/std: |
| 60 | + include: |
| 61 | + - /var/log/cassandra/*.log #File location varies, example for macOS: /opt/homebrew/var/log/cassandra/*.log |
| 62 | + start_at: beginning |
| 63 | + |
| 64 | + otlp: |
| 65 | + protocols: |
| 66 | + grpc: |
| 67 | + http: |
| 68 | + |
| 69 | + processors: |
| 70 | + resourcedetection: |
| 71 | + detectors: ["system"] |
| 72 | + system: |
| 73 | + hostname_sources: ["os"] |
| 74 | + batch: |
| 75 | + |
| 76 | + exporters: |
| 77 | + otlphttp/openobserve: |
| 78 | + endpoint: https://<your-openobserve-endpoint>/api/default |
| 79 | + headers: |
| 80 | + Authorization: Basic <your_auth_token> |
| 81 | + stream-name: cassandra |
| 82 | + |
| 83 | + service: |
| 84 | + pipelines: |
| 85 | + metrics: |
| 86 | + receivers: [jmx] |
| 87 | + processors: [resourcedetection, batch] |
| 88 | + exporters: [otlphttp/openobserve] |
| 89 | + |
| 90 | + logs: |
| 91 | + receivers: [filelog/std, otlp] |
| 92 | + processors: [batch] |
| 93 | + exporters: [otlphttp/openobserve] |
| 94 | + ``` |
| 95 | + |
| 96 | + Replace `<your-openobserve-endpoint>` and `<your_auth_token>` with values from OpenObserve’s **Data Sources → Metrics/Logs → Otel Collector**. |
| 97 | + |
| 98 | +  |
| 99 | + |
| 100 | +??? "Step 4: Restart the OpenTelemetry Collector" |
| 101 | + |
| 102 | + 1. Restart OpenTelemetry Collector |
| 103 | + ```bash |
| 104 | + systemctl restart otel-collector |
| 105 | + ``` |
| 106 | + |
| 107 | + 2. Verify the service: |
| 108 | + ```bash |
| 109 | + systemctl status otel-collector |
| 110 | + ``` |
| 111 | + |
| 112 | +??? "Step 5: Visualize in OpenObserve" |
| 113 | + |
| 114 | + 1. Go to **OpenObserve → Streams**. |
| 115 | + 2. Explore metrics such as node health, read/write latency, and JVM performance. |
| 116 | +  |
| 117 | + 3. Explore logs to debug errors, failed queries, etc. |
| 118 | +  |
| 119 | + |
| 120 | + |
| 121 | +## Troubleshooting |
| 122 | + |
| 123 | +??? "No JMX Metrics Collected" |
| 124 | + - Ensure JMX port (9000) is open and Cassandra was restarted after enabling JMX. |
| 125 | + - Verify `jar_path` points to the correct JMX metrics jar. |
| 126 | + |
| 127 | +??? "Logs Not Appearing" |
| 128 | + - Confirm Cassandra logs exist under `/var/log/cassandra/`. |
| 129 | + - Ensure `filelog` receiver has read permissions. |
| 130 | + |
| 131 | +??? "No Data in OpenObserve" |
| 132 | + - Double-check exporter endpoint and token. |
| 133 | + - Ensure Collector can reach OpenObserve. |
| 134 | + - Inspect Collector logs for errors. |
0 commit comments