0

Is there any way to log queries along with user that executed the query in Cassandra community edition?

I'm looking for a Server level solution, not driver/client based solution

Thanks!

ecunado
  • 101
  • 5

1 Answers1

0

Try nodetool settraceprobability

nodetool settraceprobability <value>

Sets the probability for tracing a request.

  • Value is a probability between 0 and 1.

Tracing a request usually requires at least 10 rows to be inserted. A probability of 1.0 will trace everything whereas lesser amounts (for example, 0.10) only sample a certain percentage of statements.

The trace information is stored in a system_traces keyspace that holds two tables – sessions and events, which can be easily queried to answer questions, such as what the most time-consuming query has been since a trace was started. Query the parameters map and thread column in the system_traces.sessions and events tables for probabilistic tracing information.

Note : Care should be taken on large and active systems, as system-wide tracing will have a performance impact. Unless you are under very light load, tracing all requests (probability 1.0) will probably overwhelm your system

If you don't want to use this, then you have log the query from the client side How to use Query Logger ?. There is no other way

Source : https://docs.datastax.com/en/cassandra/2.1/cassandra/tools/toolsSetTraceProbability.html

Ashraful Islam
  • 12,470
  • 3
  • 32
  • 53
  • Thanks for your response Ashraful. I can't find the query and the user who executed it neither on system_traces.sessions nor in system_traces.events, so I don't think this is a good solution for getting audit info I need. – ecunado Oct 09 '17 at 08:25
  • What value did you set ? – Ashraful Islam Oct 09 '17 at 08:27
  • I tried with 1 because I need every query to be logged – ecunado Oct 09 '17 at 08:27
  • If you don't want to use this, then you have log the query from the client side https://stackoverflow.com/a/40684084/2320144. There is no other way – Ashraful Islam Oct 09 '17 at 08:40