Add storage policy

Added storage policy so that deployers can override how to store the logs.
"per_host" stores logs in a sub-directory per host. "per_program" stores logs
in a single file per application which facilitates troubleshooting easy.

Change-Id: I5f71d61549f911ba8ead19e17ea481a4e0fc0262
This commit is contained in:
Ravi Kumar Boyapati 2017-03-24 10:57:56 -04:00
parent 4e1339378d
commit efd7b21798
4 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,8 @@ rsyslog_server_package_state: "latest"
rsyslog_server_spool_directory: /var/spool/rsyslog
rsyslog_server_storage_directory: /var/log/rsyslog
rsyslog_server_logrotation_window: 14 #Number of days to keep logfiles
rsyslog_server_storage_policy: "per_host" ## "per_host" stores logs in a sub-directory per host, "per_program" stores per program
# provides UDP syslog reception
rsyslog_server_udp_reception: true

View File

@ -0,0 +1,5 @@
---
features:
- Added storage policy so that deployers can override how to store the logs.
``per_host`` stores logs in a sub-directory per host. ``per_program`` stores logs
in a single file per application which facilitates troubleshooting easy.

View File

@ -1,4 +1,9 @@
{% if rsyslog_server_storage_policy == "per_host" %}
{{ rsyslog_server_storage_directory }}/**/*.log
{% endif %}
{% if rsyslog_server_storage_policy == "per_program" %}
{{ rsyslog_server_storage_directory }}/*.log
{% endif %}
{
copytruncate
weekly

View File

@ -31,7 +31,12 @@ $WorkDirectory {{ rsyslog_server_spool_directory }}
# Log all remote messages into a sub directory
{% if rsyslog_server_storage_policy == "per_host" %}
template(name="DDF" type="string" string="{{ rsyslog_server_storage_directory }}/%hostname%/%programname%.log")
{% endif %}
{% if rsyslog_server_storage_policy == "per_program" %}
template(name="DDF" type="string" string="{{ rsyslog_server_storage_directory }}/%programname%.log")
{% endif %}
ruleset(name="remote"){
*.* -?DDF
}