diff --git a/build/linux/installer/conf/td-agent-bit-rs.conf b/build/linux/installer/conf/td-agent-bit-rs.conf index 9613c270d..da3738da7 100644 --- a/build/linux/installer/conf/td-agent-bit-rs.conf +++ b/build/linux/installer/conf/td-agent-bit-rs.conf @@ -23,6 +23,19 @@ Skip_Long_Lines On Ignore_Older 2m +[INPUT] + Name tail + Tag oms.container.log.flbplugin.mdsd.* + Path /var/opt/microsoft/linuxmonagent/log/mdsd.err + Read_from_Head true + DB /var/opt/microsoft/docker-cimprov/state/mdsd-ai.db + DB.Sync Off + Parser docker + Mem_Buf_Limit 1m + Path_Key filepath + Skip_Long_Lines On + Ignore_Older 2m + [INPUT] Name tcp Tag oms.container.perf.telegraf.* diff --git a/kubernetes/linux/Dockerfile b/kubernetes/linux/Dockerfile index 1ae7bef61..b47841757 100644 --- a/kubernetes/linux/Dockerfile +++ b/kubernetes/linux/Dockerfile @@ -17,7 +17,7 @@ ENV KUBE_CLIENT_BACKOFF_BASE 1 ENV KUBE_CLIENT_BACKOFF_DURATION 0 ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR 0.9 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes init-system-helpers net-tools rsyslog cron vim dmidecode apt-transport-https gnupg && rm -rf /var/lib/apt/lists/* -COPY setup.sh main.sh defaultpromenvvariables defaultpromenvvariables-rs defaultpromenvvariables-sidecar mdsd.xml envmdsd $tmpdir/ +COPY setup.sh main.sh defaultpromenvvariables defaultpromenvvariables-rs defaultpromenvvariables-sidecar mdsd.xml envmdsd logrotate.conf $tmpdir/ WORKDIR ${tmpdir} # copy docker provider shell bundle to use the agent image diff --git a/kubernetes/linux/logrotate.conf b/kubernetes/linux/logrotate.conf new file mode 100644 index 000000000..921371fd0 --- /dev/null +++ b/kubernetes/linux/logrotate.conf @@ -0,0 +1,39 @@ +/var/opt/microsoft/linuxmonagent/log/mdsd.err { + copytruncate + rotate 7 + missingok + notifempty + delaycompress + compress + size 10M +} + +/var/opt/microsoft/linuxmonagent/log/mdsd.warn { + copytruncate + rotate 7 + missingok + notifempty + delaycompress + compress + size 10M +} + +/var/opt/microsoft/linuxmonagent/log/mdsd.info { + copytruncate + rotate 7 + missingok + notifempty + delaycompress + compress + size 10M +} + +/var/opt/microsoft/linuxmonagent/log/mdsd.qos { + copytruncate + rotate 7 + missingok + notifempty + delaycompress + compress + size 10M +} diff --git a/kubernetes/linux/main.sh b/kubernetes/linux/main.sh index 428e6f35a..4579787b3 100644 --- a/kubernetes/linux/main.sh +++ b/kubernetes/linux/main.sh @@ -521,6 +521,12 @@ else mdsd ${MDSD_AAD_MSI_AUTH_ARGS} -e ${MDSD_LOG}/mdsd.err -w ${MDSD_LOG}/mdsd.warn -o ${MDSD_LOG}/mdsd.info -q ${MDSD_LOG}/mdsd.qos & fi +# Set up a cron job for logrotation +if [ ! -f /etc/cron.d/ci-agent ]; then + echo "setting up cronjob for ci agent log rotation" + echo "*/5 * * * * root /usr/sbin/logrotate -s /var/lib/logrotate/ci-agent-status /etc/logrotate.d/ci-agent >/dev/null 2>&1" > /etc/cron.d/ci-agent +fi + # no dependency on fluentd for prometheus side car container if [ "${CONTAINER_TYPE}" != "PrometheusSidecar" ]; then if [ ! -e "/etc/config/kube.conf" ]; then diff --git a/kubernetes/linux/setup.sh b/kubernetes/linux/setup.sh index 623f33cea..51e5f9efb 100644 --- a/kubernetes/linux/setup.sh +++ b/kubernetes/linux/setup.sh @@ -16,6 +16,9 @@ wget https://github.com/microsoft/Docker-Provider/releases/download/06242021-one cp -f $TMPDIR/mdsd.xml /etc/mdsd.d cp -f $TMPDIR/envmdsd /etc/mdsd.d +#log rotate conf for mdsd and can be extended for other log files as well +cp -f $TMPDIR/logrotate.conf /etc/logrotate.d/ci-agent + #download inotify tools for watching configmap changes sudo apt-get update sudo apt-get install inotify-tools -y