How to implement auditing for cassandra data? I am looking for a open source option.
Are there any features of cassandra that help with auditing?
Can I use triggers to log the records into a table? I followed Triggers example and was able to get a record inserted into triggers_log
table when the updates occur on another table.
But not sure how do I capture the user/session
details that triggered the update. I have From CQLSH
terminal, create users
and trigger_log table
create table AUDIT_LOG ( transaction_id int, entries map<text, text>, --> to capture the modifications done to the tables user varchar, //authenticated user time timestamp, primary key(transaction_id));
CREATE TABLE users ( user_id int PRIMARY KEY, fname text, lname text );
Define the trigger on users table using CREATE TRIGGER
syntax from cqlsh
Below code so far.
public class AuditTrigger implements ITrigger {
@Override
public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily update) {
List<RowMutation> mutations = new ArrayList<RowMutation>();
for (Column column : update) {
if (column.value().remaining() > 0) {
RowMutation mutation = new RowMutation("mykeyspace", key);
//What do I need here to capture the updates to users
//table and log the updates into various columns of audit_log
mutations.add(mutation);
}
}
return mutations;
}
}
If triggers is not the correct approach (any spring AOP approach?), please suggest alternatives. I also tried Cassandra vs logging activity solution but it does not print the sql executed, authenticated user information.