Autorotate json logs for portal containers

book

Article ID: 194362

calendar_today

Updated On:

Products

CA API Developer Portal

Issue/Introduction

Some of the containers are producing very large json.log file after the portal has been running without a reboot for a 60+ days.  Looking through the docker documentation, it seems adding the following to the /etc/docker/daemon.json file could offer a solution.   Can this be added to the file without affecting portal behavior / stability:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "300M", 
    "max-file": "3"
  }
}

Environment

Release : 4.5

Component : API PORTAL

Resolution


The following process applies to all newly created containers after restart.
You can edit the daemon configuration file. Please create the file if it doesn't exist.

1. vi /etc/docker/daemon.json
2. Add the following lines to file:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "30m",
"max-file": "3"
}
}

Results


[[email protected] ~]# docker ps | grep abde
abde8df95928 apim-portal.packages.ca.com/apim-portal/druid:4.4 "/opt/druid-entry.sh" 3 hours ago Up 3 hours (healthy) portal_historical.1.mrhjg1096pi2lvkv1301v9u0j
[[email protected] ~]#

Container

Logs for druid rotated twice

[[email protected] abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7]# pwd
/var/lib/docker/containers/abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7
[[email protected] abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7]# ls -la
total 62668
drwx------. 4 root root 4096 Jul 2 19:00 .
drwx------. 21 root root 4096 Jul 2 15:57 ..
-rw-r-----. 1 root root 3477935 Jul 2 19:00 abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7-json.log
-rw-r-----. 1 root root 30000028 Jul 2 18:58 abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7-json.log.1
-rw-r-----. 1 root root 30000163 Jul 2 18:37 abde8df959287870e6dff542e202ce60bff03f17d9984f01a63c1f74e82279b7-json.log.2