Summary

How to keep database tables under control in environments that produce many audit messages.


Problem


In certain environments that produce many audit messages, the database table that contains these messages can become quite large. 


Solution


 In an effort to keep this table under control, here are some settings to look for, and ways to manually clean up the database, if required.  


Automating the cleanup

The audit records cleanup is configured from the UI, under Settings tab.


1. Configure the time frame, in days, when the audit records will be kept. 

2. Set the "clean time", which is the time of the scheduled task. 


Manual cleanup

In case a manual intervention is needed to cleanup the records, use the following procedure:


1. Connect to Aqua's DB by using exec command

    docker exec -it <container id> sh

2. Login to postgres user

    su - postgres

3. Launch psql

    psql

4.  Connect to audit schema

    \connect slk_audit

5. View audit records

    select *  from audit WHERE to_timestamp(createtime) < NOW() - INTERVAL '14 days';

6. Delete records

    delete from audit WHERE to_timestamp(createtime) < NOW() - INTERVAL '14 days';