Performing Log Cleanup

Log cleanup is done by an automated process running in the log container at regular intervals. This clean up utility would clean the logs as per the configuration of disk.usage.warning and disk.usage.critical levels. By default these values are set to disk.usage.warning=70 disk.usage.critical=80. This number represents the percentage of the total disk allocated to log container.

Log cleanup cron can be found at /etc/cron.d/log-cleanup-cron.

log-cleanup-cron

*/15 * * * * root /usr/bin/flock -w 0 /var/lock/logcleanup-task /usr/bin/python 
/opt/mashery/containeragent/bin/cleanup_disk.py 2>&1 | tee -a /var/log/logcleanuu
pcron.log
User can change the disk warning and critical level in the file /opt/mashery/containeragent/bin/logservicecleanup.ini

logservicecleanup.ini

[PATH_NOT_TO_BE_DELETED]
#please provide other log path if those logs needs to be excluded from deletion. But would be deleted after 31 days or
# size of that dir is reached the limit allowed for that log path.
# e.g. /mnt/log1,/mnt/log2
log.path=
 
[BASE_PATH]
# base path for the log directory
# e.g. /mnt/data
base.path=/mnt/data
 
[OTHER_LOG]
# duration for which the logs need to be kept. It is in days
# This would keep the other logs of log container.
other.log.duration=1
other.log.path=/var/log/,/tmp
 
[CONTAINER_LOG]
# duration for which the logs need to be kept. It is in days
# This would keep the application logs of all the containers
container.log.duration=4
 
[METRIC_LOG]
# duration for which the logs need to be kept. It is in days
# This would keep the metrics log for the below mentioned days
metric.log.duration=4
 
[ACCESS_LOG]
# duration for which the logs need to be kept. It is in days
# This would keep the access logs for the below mentioned days
access.log.duration=31
access.log.path=/mnt/data/trafficmanager
 
[DISK_USAGE_MONITOR]
#This is the level set for cleaning up logs. Below values represents % of the configured disk
disk.usage.warning=70
disk.usage.critical=80
1. PATH_NOT_TO_BE_DELETED : It is the path which user doesn't want utility to clean up for later debugging purpose. This has to be given in comma separated value.
 
2. BASE_PATH : This is the base path where the logs are stored.
 
3. OTHER_LOG : This is the section for log container's /var/log/ and /tmp logs and "other.log.duration" property is used to define days for which user wants to keep the logs if the disk usage is above warning level.
 
4. CONTAINER_LOG : This is the section for application logs of containers and "container.log.duration" property is used to define days for which user wants to keep the logs if the disk usage is above warning level.
 
4. METRIC_LOG : This is the section for all the metrics logs and "metric.log.duration" property is used to define days for which user wants to keep the logs if the disk usage is above the warning level.
 
5. ACCESS_LOG : This is the section for all the access logs and "access.log.duration" property is used to define days for which user wants to keep the access logs if the disk usage is above critical level.
"access.log.path" property is used to define the base path for the access logs storage.
 
6. DISK_USAGE_MONITOR : This is the section to define the disk usage warn and critical level. This represents the percentage of the disk usage.
"disk.usage.warning" and "disk.usage.critical" properties to define the threshold level as per disk usage.
 
NOTE : Threshold level is totally dependent on inflow of logs and the volume of disk that is configured. As the log cleanup utility would run every 15 minutes log clean up would be continuous exercise. But user is free to set the above parameters as per the need and requirements.