...
- Open the
<IS_HOME>/repository/conf/analytics/analytics-config.xml
file. Change the contents under the
<analytics-data-purging>
property as shown below:Code Block language xml <analytics-data-purging> <purging-enable>true</purging-enable> <cron-expression>0 0 12 * * ?</cron-expression> <purge-include-tables> <table>.*</table> </purge-include-tables> <data-retention-days>365</data-retention-days> </analytics-data-purging>
- Save your changes.
Verify purging
To verify if the automatic purging task runs successfully, do the following.
Check the server log at the relevant time at which the task is scheduled to run. You should see a log similar to the one shown below.
Code Block TID: [-1234] [] [2019-10-31 00:00:03,245] INFO {org.wso2.carbon.analytics.dataservice.core.tasks.AnalyticsGlobalDataPurgingTask} - Records persist before Sun Oct 27 23:59:59 MDT 2019[1572242399999] going to purge from ORG_WSO2_APIMGT_STATISTICS_PERHOURRESPONSE in tenant[-1234] {org.wso2.carbon.analytics.dataservice.core.tasks.AnalyticsGlobalDataPurgingTask}
Check the difference in the database table size to check if it has reduced once the purging task has run. You can run a database query similar to the MYSQL query shown below to check the size of the event store table.
Code Block language sql SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as size FROM information_schema.TABLES WHERE table_schema = "<analytics_eventsore_database_name>" ORDER BY size DESC;
Tip For instructions on how to retrieve the relevant table names related to purging, see Retrieving the Actual Name of a Table in the WSO2 Data Analytics Server documentation.