Rotate Kibana logs

Change-Id: I8b0c419c3cd67ffec20b0cd5ed733c6f057f1147
This commit is contained in:
Swann Croiset 2016-06-08 18:03:21 +02:00
parent 0c696459c9
commit 156cd78dec
4 changed files with 36 additions and 0 deletions

View File

@ -34,8 +34,12 @@ class lma_logging_analytics::kibana (
ensure => $version,
}
# The init script always creates /var/log/kibana and sets appropriate rights.
$log_dir = '/var/log/kibana'
file { '/opt/kibana/config/kibana.yml':
ensure => present,
# This template uses $log_dir
content => template('lma_logging_analytics/kibana4.yaml.erb'),
notify => Service['kibana'],
require => Package['kibana'],
@ -48,4 +52,14 @@ class lma_logging_analytics::kibana (
hasrestart => true,
require => Package['kibana'],
}
file { '/etc/logrotate.d/kibana.conf':
ensure => present,
# This template uses $log_dir
content => template('lma_logging_analytics/kibana_logrotate.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => Package['kibana'],
}
}

View File

@ -28,4 +28,6 @@ describe 'lma_logging_analytics::kibana' do
:ensure => '42.24')
}
it { should contain_service('kibana')}
it { is_expected.to contain_file('/etc/logrotate.d/kibana.conf') }
end

View File

@ -2,3 +2,4 @@ elasticsearch.url: "<%= @es_scheme %>://<%= @es_host %>:<%= @es_port %>"
server.host: <%= @listen_address %>
server.port: <%= @listen_port %>
kibana.defaultAppId: "dashboard/Logs"
logging.dest: "<%= @log_dir %>/kibana.log"

View File

@ -0,0 +1,19 @@
# managed by puppet
<%= @log_dir %>/*.log {
copytruncate
compress
delaycompress
missingok
notifempty
# logrotate allows to use only year, month, day and unix epoch
dateext
dateformat -%Y%m%d-%s
# number of rotated files to keep
rotate 10
# do not rotate files unless both size and time conditions are met
hourly
minsize 20M
# force rotate if filesize exceeded 100M
maxsize 100M
}