Configuring Retention for Ranger Audits in Solr¶
In Self Managed deployments, audit logs are stored in Apache Solr which is used by Privacera Portal to display audit logs. By default, audit logs are retained for 90 days in Solr. You can configure the retention period for Ranger audit logs in Solr.
The default retention period for Ranger audit logs in Solr is configured starting from version 9.0.7.1. If you wish to retain logs for a different period, you should configure it according to your requirements before upgrading to version 9.0.7.1 or higher.
Prerequisites¶
Prerequisite | Description |
---|---|
Apache Solr | In Self Managed deployments, Apache Solr is installed by default |
Setup¶
Follow these steps to configure the retention period for Ranger audits in Solr:
- SSH into the instance where Privacera Manager is installed.
- Navigate to the
privacera-manager
directory using the following command:Bash - Run the following command to copy the sample vars. The
-n
flag ensures that the file is not overwritten if it already exists.Bash - Run the following command to open the
.yml
file for editing.Bash - Add or update the following property:
Variable | Definition |
---|---|
MAX_AUDIT_RETENTION_DAYS | Retention period for ranger access audit logs in days. Default is 90 Days. |
YAML | |
---|---|
Validation¶
To confirm that the setup is successful, after running the above steps and make some access operation which will generate audit logs. The new audit logs will have the TTL set as per the configuration. If you have access to the Solr UI, you can verify the TTL configuration for the ranger_audits collection for the newly created audit logs.
Here is a sample solrconfig file with ranger-audits TTL set to +7DAYS:
Here is a sample ranger-audit with TTL set to +7DAYS:
Purging Historical Ranger Audits¶
Ranger access audits created before upgrade to Privacera version 9.0.7.1 might not have TTL set and needs to be manually deleted from Apache Solr. This can be done by making HTTP post requests to the Solr collection to delete the audits greater than the retention period.
Here is a sample script to delete ranger-audits from Solr manually. Please use this script as a reference and modify it as per your requirement.
This assumes that Apache Solr has been configured without basic authentication. If you have configured basic authentication, you need to pass the credentials in the curl command.
Create a script file called delete_ranger_audits.sh
with the following content. Update SOLR_URL with your Solr URL
Here is a sample script to delete ranger-audits from Solr manually.
- Make the Script Executable
Bash - Run the Script