Why cloud-init logs are not autorotated considering it can grow indefinitely and fill up partition size quickly

Asked by Neha

The following log files :

/var/log/cloud-init.log
/var/log/cloud-init-output.log

produced by Cloud-Init are not rotated. As a consequence, they keep growing indefinitely and can fill up the underlying partition.

On investigation , found logrotate on ubuntu that supports rotation of logs
But can you tell why cloud-init logs are not auto-rotated? Do you have any future plans to provide this feature in-built from Microsoft?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu cloud-init Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Neha (nehar) said :
#1
Revision history for this message
Bernard Stafford (bernard010) said (last edit ):
#2

Change /var/log/syslog to:
{
    rotate 7
    daily
    ...
    postrotate
        service rsyslog rotate >/dev/null 2>&1 || true
    endscript
}
For each rotated rsyslog files triggered logrotate manually with "/usr/sbin/logrotate /etc/logrotate.conf" .

Quote: " Do you have any future plans to provide this feature in-built from Microsoft?" - No -
Microsoft has Proprietary copyright.
Please feel free to submit a bug report. Perhaps something can be built that will accomplish just that.

Revision history for this message
Alessandro Carini (carini) said :
#3

Problem is still present on Ubuntu 22.04.4 LTS (Microsoft Azure image).

I just added manually a file /etc/logrotate.d/cloud-init with

/var/log/cloud-init.log /var/log/cloud-init-output.log {
 rotate 5
 missingok
 notifempty
 compress
 delaycompress
 size 50M
 copytruncate
}

on all of my machine

Can you help with this problem?

Provide an answer of your own, or ask Neha for more information if necessary.

To post a message you must log in.