From 00efa603c27660cd21e3f276f18a96486e7b25dc Mon Sep 17 00:00:00 2001 From: Les Aker Date: Wed, 3 Jan 2024 22:27:17 -0500 Subject: [PATCH] add rotation setting --- manifests/client.pp | 14 ++++++++++++++ templates/rotate.conf.erb | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 templates/rotate.conf.erb diff --git a/manifests/client.pp b/manifests/client.pp index 6b47bdb..3dc258d 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -4,11 +4,13 @@ # @param password sets the promtail user password to submit logs # @param logpaths sets additional directories to pull logs from # @param syslog_sources sets IPs to expect syslog data from +# @param journald_retention sets how long to retain local journal data class loki::client ( String $server, String $password, Hash[String, String] $logpaths = {}, Array[String] $syslog_sources = [], + String $journald_retention = '0', ) { include loki @@ -31,6 +33,18 @@ enable => true, } + file { '/etc/systemd/journald.conf.d': + ensure => directory, + owner => root, + group => root, + mode => '0755', + } + + file { '/etc/systemd/journald.conf.d/rotate.conf': + ensure => file, + content => template('loki/rotate.conf.erb'), + } + if $syslog_sources.length > 0 { $syslog_sources.each |String $source| { firewall { "100 allow syslog udp input from ${source}": diff --git a/templates/rotate.conf.erb b/templates/rotate.conf.erb new file mode 100644 index 0000000..b114276 --- /dev/null +++ b/templates/rotate.conf.erb @@ -0,0 +1,2 @@ +[Journal] +MaxRetentionSec=<%= @journald_retention %>