Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



navjyotnishant avatar image
navjyotnishant asked Erick Ramirez answered

How is Cassandra able to track connection on a node in system_view.clients virtual table?


Any idea how it is able to track the connection on a node? is it somehow pulling the info from Driver/initiator? system_traces?

If this is something for which system traces need to be enabled first the we are actually back to where we have started. :(

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

There were several changes made to Cassandra 4.0 to make this happen.

One of those changes (CASSANDRA-14524) involved a refactor of client (app/driver) metrics ( and there is now a new class that tracks metadata on client connections which include the following:

    public Map<String, String> asMap()
        return ImmutableMap.<String, String>builder()
                           .put(ADDRESS, remoteAddress().toString())
                           .put(USER, username().orElse(UNDEFINED))
                           .put(VERSION, String.valueOf(protocolVersion()))
                           .put(DRIVER_NAME, driverName().orElse(UNDEFINED))
                           .put(DRIVER_VERSION, driverVersion().orElse(UNDEFINED))
                           .put(REQUESTS, String.valueOf(requestCount()))
                           .put(KEYSPACE, keyspace().orElse(""))
                           .put(SSL, Boolean.toString(sslEnabled()))
                           .put(CIPHER, sslCipherSuite().orElse(UNDEFINED))
                           .put(PROTOCOL, sslProtocol().orElse(UNDEFINED))

This data is exposed by the class through the client stats command:

$ nodetool clientstats

The client metrics refactor setup the stage to expose information on the active connected clients ( in the virtual table system_view.clients through the class (CASSANDRA-14458):

            result.row(remoteAddress.getAddress(), remoteAddress.getPort())
                  .column(HOSTNAME, remoteAddress.getHostName())
                  .column(USERNAME, client.username().orElse(null))
                  .column(CONNECTION_STAGE, client.stage().toString().toLowerCase())
                  .column(PROTOCOL_VERSION, client.protocolVersion())
                  .column(DRIVER_NAME, client.driverName().orElse(null))
                  .column(DRIVER_VERSION, client.driverVersion().orElse(null))
                  .column(REQUEST_COUNT, client.requestCount())
                  .column(SSL_ENABLED, client.sslEnabled())
                  .column(SSL_PROTOCOL, client.sslProtocol().orElse(null))
                  .column(SSL_CIPHER_SUITE, client.sslCipherSuite().orElse(null));


10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.