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

vijayshanker.oracle_94842 avatar image
vijayshanker.oracle_94842 asked ·

Is there a way to know when a role/user was created?

is there a way to find the role/user creation time other than auditlogs.
Also can we find its TTL too

roles
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 ·

@vijayshanker.oracle_94842 you can use the CQL function WRITETIME() to get the timestamp for when the data was written.

To illustrate, here is an example where I created the role vijay:

cassandra@cqlsh> CREATE ROLE vijay WITH LOGIN = true AND PASSWORD = 'xxxxx';

and here is an example output for the WRITETIME() function:

cassandra@cqlsh> SELECT role, WRITETIME(can_login) FROM system_auth.roles WHERE role = 'vijay';

 role  | writetime(can_login)
-------+----------------------
 vijay |     1570581776845000

For more info, see CQL native functions.

On the TTL question, you can't set roles to expire in Cassandra so you can't use the TTL() function.

P.S. There are various ways of converting timestamps to a date. The simplest way is to use an online tool like https://www.epochconverter.com/. FWIW, 1570581776845000 is equivalent to October 9, 2019 12:42 GMT. Cheers!

1 comment 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.

Appreciate you as usually you are great

0 Likes 0 · ·