Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logfiles like consul-1685110072803312715.log-20230525 not compressed/deleted #519

Open
reini-1 opened this issue May 26, 2023 · 3 comments

Comments

@reini-1
Copy link

reini-1 commented May 26, 2023

We use hashicorp consul that creates logfiles like consul-1685111153157372329.log.

logrotate rotates the logfile, but did not compress or delete older logfiles, resulting in files like this:

consul-1683946289102308688.log-20230514
consul-1684033238541094123.log-20230515
consul-1684123574095901597.log-20230516
consul-1684210175940865576.log-20230517
consul-1684229280612481299.log-20230517
consul-1684276259117751050.log-20230518
consul-1684292790837539605.log-20230518
consul-1684379202722050041.log-20230519
consul-1684465686035337976.log-20230520
consul-1684552517008826832.log-20230521
consul-1684649168435052308.log-20230522
consul-1684752755033723960.log-20230523
consul-1684894608194357266.log-20230525
consul-1684982444114440391.log-20230525
consul-1685069557047483176.log-20230525
consul-1685110072803312715.log-20230525
consul-1685111153157372329.log

When doing a forced logrotate I saw there seems to be a problem with the glob pattern:

rotating pattern: /var/log/consul/*.log  forced from command line empty log files are not rotated, old logs are removed
switching euid from 0 to 998 and egid from 0 to 998 (pid 3271001)
considering log /var/log/consul/consul-1684982444114440391.log
  Now: 2023-05-26 15:58
  Last rotated at 2023-05-26 00:00
  log needs rotating
considering log /var/log/consul/consul-1685069557047483176.log
  Now: 2023-05-26 15:58
  Last rotated at 2023-05-26 14:00
  log needs rotating
rotating log /var/log/consul/consul-1684982444114440391.log, log->rotateCount is -1
dateext suffix '-20230525'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
renaming /var/log/consul/consul-1684982444114440391.log to /var/log/consul/consul-1684982444114440391.log-20230525
rotating log /var/log/consul/consul-1685069557047483176.log, log->rotateCount is -1
dateext suffix '-20230525'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
renaming /var/log/consul/consul-1685069557047483176.log to /var/log/consul/consul-1685069557047483176.log-20230525
switching euid from 998 to 0 and egid from 998 to 0 (pid 3271001)

I think the problem is the glob pattern, looking for -YYYYMMDD, that cannot be found on the first place, because there is something like -nnnnnnnn.

My config is the following:

$ for i in /etc/logrotate.conf /etc/logrotate.d/consul; do printf "\n#### $i ####\n"; grep -vE '^#|^$' $i; done

#### /etc/logrotate.conf ####
daily
rotate 31
create
compress
compresscmd /usr/bin/zstd
compressext .zst
compressoptions -9 -T0 --long
uncompresscmd /usr/bin/unzstd
dateext
include /etc/logrotate.d

#### /etc/logrotate.d/consul ####
/var/log/consul/*.log {
        rotate 30
        daily
        notifempty
        missingok
        dateext
        dateyesterday
        delaycompress
        nocreate
        su consul consul
}

Is there a solution to fix this problem?

Thanks in advance.

@cgzones
Copy link
Member

cgzones commented May 26, 2023

No, there is currently no solution within logrotate for this.
logrotate treats consul-1685111153157372329.log and consul-1685110072803312715.log-20230525 as two different log files (like var/log/apache/acces.log and /var/log/apache/error.log) and not the latter a rotated version of the former.

@anotherbridge
Copy link

@cgzones Is there any update on this? If not is there a workaround to rotate these logfiles?

@reini-1
Copy link
Author

reini-1 commented Jan 20, 2024

My workaround is a custom shell script to rotate these logs ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants