Fix up log rotation

Turns out this is a bit of a pain, and we found out via a full disk.

Firstly, carbon wants to rotate it's own log files, but doesn't
compress or cleanup.  Disable this with ENABLE_LOGROTATION=False,
which has been around for a while.  This is copied from the upstream
example config.

Secondly, we were missing the console.log file.  Change the rotate to
just one for "*.log", and also add "sharedscripts" so the post-rotate
is only run once per rotation of all files.

Thirdly, copytruncate doesn't work [2].  It needs to be "nocreate";
the file is moved and carbon starts a new one (as suggested by the
config comment).  This is updated in the combined rotate section.

[1] https://github.com/graphite-project/carbon/pull/68
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733856

Change-Id: I946bb728971db79a2f4d08f2787c0768b958fb53
This commit is contained in:
Ian Wienand 2018-02-07 10:28:02 +11:00
parent 4a30897c05
commit dfc94e4fd9
3 changed files with 10 additions and 35 deletions

View File

@ -176,37 +176,16 @@ class graphite(
}
include ::logrotate
logrotate::file { 'querylog':
log => '/var/log/graphite/carbon-cache-a/query.log',
logrotate::file { 'graphite-carbon':
log => '/var/log/graphite/carbon-cache-a/*.log',
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
logrotate::file { 'listenerlog':
log => '/var/log/graphite/carbon-cache-a/listener.log',
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
logrotate::file { 'createslog':
log => '/var/log/graphite/carbon-cache-a/creates.log',
options => [
'compress',
'copytruncate',
'nocreate',
'missingok',
'rotate 7',
'daily',
'notifempty',
'sharedscripts',
],
}

View File

@ -71,16 +71,8 @@ describe 'puppet-graphite module', :if => ['debian', 'ubuntu'].include?(os[:fami
end
end
describe file('/etc/logrotate.d/querylog') do
its(:content) { should include '/var/log/graphite/carbon-cache-a/query.log' }
end
describe file('/etc/logrotate.d/listenerlog') do
its(:content) { should include '/var/log/graphite/carbon-cache-a/listener.log' }
end
describe file('/etc/logrotate.d/createslog') do
its(:content) { should include '/var/log/graphite/carbon-cache-a/creates.log' }
describe file('/etc/logrotate.d/graphite-carbon') do
its(:content) { should include '/var/log/graphite/carbon-cache-a/*.log' }
end
describe file('/etc/statsd/config.js') do

View File

@ -31,6 +31,10 @@ LOCAL_DATA_DIR = /var/lib/graphite/storage/whisper/
#
#LOCAL_DATA_DIR = /opt/graphite/storage/whisper/
# Enable daily log rotation. If disabled, a new file will be opened whenever the log file path no
# longer exists (i.e. it is removed or renamed)
ENABLE_LOGROTATION = False
# Specify the user to drop privileges to
# If this is blank carbon runs as the user that invokes it
# This user must have write access to the local data directory