Toggle Menu

Full Query Logging

Video: Use Full Query Logging to analyze query performance

Full Query Logging

Sometimes it is helpful to be able to see the exact CQL queries that client applications are sending to your cluster. This is true when you have poorly performing queries that you need to analyze and try to optimize. Or perhaps you have queries that are producing results that are not what you expected. Full Query Logging was designed to help in these cases.

Full Query Logging is also useful as a way of capturing live query traffic against a cluster so that you can replay it at a later time, perhaps in a development or test environment.

Next: Enable Full Query Logging
Full Query Logging
Enable Full Query Logging

Enable Full Query Logging

Full Query logging is disabled by default in Cassandra. There are two ways to configure full query logging: dynamically using nodetool or statically using cassandra.yaml.

A configuration using nodetool overrides a configuration defined in cassandra.yaml and does not persist across server restarts.

Next: Configurable Properties

Configurable Properties

The following properties under the full_query_logging_options section in the cassandra.yaml file are used to configure full query logging:

  • log_dir: Enable full query logging by setting this property to an existing directory location.
  • roll_cycle: Sets the frequency at which log segments are rolled - DAILY, HOURLY (the default), or MINUTELY.
  • block: Determines whether writes to the full query log will block query completion if full query logging falls behind, defaults to true.
  • max_queue_weight: Sets the maximum size of the in-memory queue of full query logs to be written to disk before blocking occurs, defaults to 256 MiB.
  • max_log_size: Sets the maximum size of full query log files on disk (default 16 GiB). After this value is exceeded, the oldest log file will be deleted.
  • archive_command: Optionally, provides a command that will be used to archive full query log files before deletion.
  • max_archive_retries: Sets a maximum number of times a failed archive command will be retried (defaults to 10)
Next: Resource Limits on Queued Messages
Configurable Properties
Full Query Logging Tool

Resource Limits on Queued Messages

(CASSANDRA-15066) This feature simply puts bounds on the number of unsent or unprocessed messages that can be in the messaging queues. Without this, a node's memory usage can grow unbounded and run out of memory. In general, the defaults can be used as currently set. Advanced users have the option to tune these settings based on the specific environment.

Next: Virtual Tables for Messaging Metrics

Virtual Tables for Messaging Metrics

With the introduction of virtual tables in 4.0, it’s easy to get access to messaging metrics. Within the system_views keyspace, there are two new virtual tables named internode_inbound and inernode_outbound. The inbound table contains these metrics:

  • Bytes and count of messages that could not be serialized or flushed due to an error
  • Bytes and count of messages scheduled
  • Bytes and count of messages successfully processed
  • Bytes and count of messages successfully received
  • Nanoseconds and count of messages throttled
  • Bytes and count of messages expired
  • Corrupt frames recovered and unrecovered

The outbound table contains these metrics:

  • Bytes and count of messages pending
  • Bytes and count of messages sent
  • Bytes and count of messages expired
  • Bytes and count of messages that could not be sent due to an error
  • Bytes and count of messages overloaded
  • Active Connection Count
  • Connection Attempts
  • Successful Connection Attempts
Next: Skill Building
What is in the log?

Skill Building

Let’s try out some of these improvements.

Full Query Logging

Learn how to enable full query logging in Cassandra and how to read the logs with fqltool

CONTRIBUTORS

Cassandra 4.x full query logging enables you to get the exact CQL query strings used by your client applications. This information can be used for:

  • Analyzing poorly performing queries
  • Debugging queries that are producing incorrect results
  • Live traffic capture and replay
  • Troubleshooting/Debugging

In this scenario you will:

  • Enable and disable full query logging statically (in cassandra.yaml) and dynamically (using nodetool).
  • Learn features of the full query logging tool fqltool
  • Read and interpret full query logs

Time to Complete

15 minutes

Difficulty

Beginner

Share

Do you have a suggestion or issue you’ve discovered?

Share Feedback

More Resources

Learn more about Full Query Logging

Full Query Logging Documentation

Full Query Logging Documentation

Learn More
Query and Audit Logging in Cassandra 4.0

Query and Audit Logging in Cassandra 4.0 - Vinay Kumar Chella

Learn More