From 65d7113e8fdfd830c270840325436b5e9332d847 Mon Sep 17 00:00:00 2001 From: maxgutman Date: Mon, 3 Feb 2014 13:59:09 -0800 Subject: [PATCH 1/3] Add specific file logging --- manifests/rsyslog.pp | 7 +++++++ templates/log.conf.erb | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 templates/log.conf.erb diff --git a/manifests/rsyslog.pp b/manifests/rsyslog.pp index c29a9ec..e8976f1 100644 --- a/manifests/rsyslog.pp +++ b/manifests/rsyslog.pp @@ -76,6 +76,13 @@ refreshonly => true, } + define logfile($logname,$filepath,$severity='info') { + file { "/etc/rsyslog.d/$logname.conf": + content => template("log.conf.erb"), + notify => Exec["restart_rsyslogd"], + } + } + } # vi:syntax=puppet:filetype=puppet:ts=4:et: diff --git a/templates/log.conf.erb b/templates/log.conf.erb new file mode 100644 index 0000000..5dace6f --- /dev/null +++ b/templates/log.conf.erb @@ -0,0 +1,12 @@ +# Loggly +$ModLoad imfile +$InputFilePollInterval 10 + +#<%= logname %> +$InputFileName <%= filepath %> +$InputFileTag <%= logname %>: +$InputFileStateFile stat-<%= logname %>-log +$InputFileSeverity <%= severity %> +$InputRunFileMonitor + + From ce47a9bb43be863973c646c305082e68608ab2aa Mon Sep 17 00:00:00 2001 From: maxgutman Date: Mon, 3 Feb 2014 14:04:06 -0800 Subject: [PATCH 2/3] Fix path to log file --- manifests/rsyslog.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/rsyslog.pp b/manifests/rsyslog.pp index e8976f1..dba073f 100644 --- a/manifests/rsyslog.pp +++ b/manifests/rsyslog.pp @@ -78,7 +78,7 @@ define logfile($logname,$filepath,$severity='info') { file { "/etc/rsyslog.d/$logname.conf": - content => template("log.conf.erb"), + content => template("loggly/log.conf.erb"), notify => Exec["restart_rsyslogd"], } } From f015fdcc4a16f737d3386652fbee31e7acc19985 Mon Sep 17 00:00:00 2001 From: maxgutman Date: Mon, 3 Feb 2014 14:22:34 -0800 Subject: [PATCH 3/3] Add custom logging example into README --- README.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f58bab..761e08f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Automate your Loggly config with Puppet -If you've ever had to manage servers, you're probably very familiar with an age-old problem: "How do I keep track of what's happening on all of my systems?" +If you've ever had to manage servers, you're probably very familiar with an age-old problem: "How do I keep track of what's happening on all of my systems?" -[Loggly](http://loggly.com/) is a tool that can help you solve that very problem by bringing your logs from all of your systems into a central, easy-to-use dashboard. +[Loggly](http://loggly.com/) is a tool that can help you solve that very problem by bringing your logs from all of your systems into a central, easy-to-use dashboard. Unfortunately, if you've got more than a handful of servers, it quickly becomes tedious to manage their configuration by hand. Since we're still years away from being able to delegate the setup to robot minions, the Loggly team has created a [Puppet](http://puppetlabs.com/puppet/what-is-puppet) module to get Puppet users up and running right away. @@ -180,9 +180,32 @@ node 'my_server_node.example.net' { } } ``` -Unfortunately, the packages in the EPEL repository for syslog-ng are not compiled with TLS support by default, so TLS is +Unfortunately, the packages in the EPEL repository for syslog-ng are not compiled with TLS support by default, so TLS is disabled by default on Red Hat-style distributions. Data sent from your systems to Loggly will not be encrypted by default. + +#### If you want to log custom logfiles + +```puppet + +node 'my_server_node.example.net' { + class { 'loggly::rsyslog': + customer_token => 'de7b5ccd-04de-4dc4-fbc9-501393600000', + } + + loggly::rsyslog::logfile { "custom-logfile": + logname => "custom-logfile", + filepath => "/var/log/custom-logfile.log" + } + + loggly::rsyslog::logfile { "mysql": + logname => "mysql", + filepath => "/var/log/mysqld.log" + } +} +``` + + #### Additional information More information on available configuration options can be found in the source code for the Loggly Puppet module.