Enable metrics collection in Cassandra drivers

Performance monitoring is an important aspect of the software development lifecycle. Metrics-based alerts and application monitoring frameworks help you identify, track, and resolve performance issues quickly.

Monitoring driver metrics can help you identify and troubleshoot performance issues in your applications, such as latency spikes, connection problems, and timeouts. Targeted monitoring of components, such as drivers, helps you find the source of an issue and begin troubleshooting more quickly.

Cassandra drivers expose metrics through language-specific libraries and APIs. To troubleshoot performance issues, DataStax recommends collecting most driver metrics in Prometheus or other compatible monitoring tools. Then, you can set up alerts in your preferred monitoring tool.

C/C++ driver metrics

The C/C++ driver tracks its metrics through the internal CassMetrics object. This object contains information about requests (latency and throughput), stats (connections), and errors (timeouts). For more information, see C/C++ driver metrics.

C# driver metrics

C# driver metrics are disabled by default.

To enable metrics, use the Builder.WithMetrics() method when creating the session.

To export metrics to a monitoring tool, use the App.Metrics Provider extension package.

For speculative execution, use the node-level metric speculative-executions.

For more information, including a list of metrics, see C# driver metrics.

Java driver metrics

Java driver metrics are disabled by default. To enable metrics, use advanced.metrics to select your metrics library and the metrics that you want to monitor.

Depending on your driver version, the Java driver can report metrics to various metrics libraries, including built-in support for popular metrics libraries.

Example: Select metrics library
// create any type of registry depending on used library
Object registry = new SimpleMeterRegistry();
CqlSession session = CqlSession.builder()
    // ...
    .withMetricRegistry(registry)
    .build()

You must specify each metric that you want to capture. For a full list of available metrics, see the documentation for your version of the Java driver:

Example: Enable specific metrics
datastax-java-driver {
  advanced.metrics {
    session {
      enabled = [
        bytes-sent,
        bytes-received,
        connected-nodes,
        cql-requests,
        cql-client-timeouts,
      ]
      cql-requests {
          highest-latency = 3 seconds
          lowest-latency = 1 millisecond
          significant-digits = 3
          refresh-interval = 5 minutes
      }
    }
    node {
      enabled = [
        pool.open-connections,
        pool.available-streams,
        pool.in-flight,
        cql-messages,
        errors.request.unsent,
        errors.request.aborted,
        errors.request.write-timeouts,
        errors.request.read-timeouts,
        errors.request.unavailables,
        errors.request.others,
        retries.total,
        retries.aborted,
        retries.read-timeout,
        retries.write-timeout,
        retries.unavailable,
        retries.other,
        ignores.total,
        ignores.aborted,
        ignores.read-timeout,
        ignores.write-timeout,
        ignores.unavailable,
        ignores.other,
        errors.connection.init
    ]
    cql-messages {
      highest-latency = 3 seconds
      lowest-latency = 1 millisecond
      significant-digits = 3
      refresh-interval = 5 minutes
    }
    expire-after = 1 hour
    }
  }
}

You can also use an external metric registry:

For speculative execution, use the speculative-executions metric:

For more information, see the following documentation:

Node.js driver metrics

The Node.js driver’s metrics module exposes internal driver metrics in the form of counters:

  • ClientMetrics: An interface that can be used by metrics libraries, service providers, and the community to implement support for existing toolkits like DataDog, Prometheus, and Measured.

  • DefaultMetrics: A default implementation of ClientMetrics that exposes driver metrics as Node.js events, and then push them to your application metrics toolkit.

For speculative execution, use the EventEmitter speculativeExecutions.

For more information, see the documentation for your version of the Node.js driver:

Python driver metrics

Python driver metrics are disabled by default.

The Python driver offers optional metrics support that requires the scales library.

To enable metrics support, install the scales dependency, and then create the Cluster object with metrics_enabled set to True. To access the reported statistics, use a simple HTTP server to spot check the metrics.

Alternatively, you can use GraphitePusher to collect and report metrics to Graphite.

For more information, see the documentation for your version of the Python driver:

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM