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

 

question

navjyotnishant avatar image
navjyotnishant asked ·

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

[FOLLOW UP QUESTION TO #6092]

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. :(

cassandramonitoring
10 |1000 characters needed characters left characters exceeded

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 (o.a.c.metrics.ClientMetrics.java) and there is now a new ConnectedClient.java 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))
                           .build();
    }

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

$ nodetool clientstats

The client metrics refactor setup the stage to expose information on the active connected clients (ConnectedClient.java) in the virtual table system_view.clients through the ClientsTable.java 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));

Cheers!

Share
10 |1000 characters needed characters left characters exceeded

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