Ema has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389515 )

Change subject: cache: send varnish logs to logstash
......................................................................

cache: send varnish logs to logstash

This was previously merged (dfaddfb2932a9fdde29170f3596df402213ca2ac)
but the change was incorrect in the way it invoked rsyslog::conf.

Bug: T63782
Change-Id: I63a3bea8cb22be9124f5de5866b47aeaed19001d
---
M modules/profile/manifests/cache/base.pp
M modules/varnish/manifests/logging.pp
M modules/varnish/templates/initscripts/varnish.systemd.erb
A modules/varnish/templates/rsyslog.conf.erb
4 files changed, 36 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/15/389515/1

diff --git a/modules/profile/manifests/cache/base.pp 
b/modules/profile/manifests/cache/base.pp
index ac93afd..07c89bd 100644
--- a/modules/profile/manifests/cache/base.pp
+++ b/modules/profile/manifests/cache/base.pp
@@ -20,6 +20,8 @@
     $purge_varnishes = hiera('profile::cache::base::purge_varnishes', 
['127.0.0.1:3128', '127.0.0.1:3127']),
     $fe_runtime_params = hiera('profile::cache::base::fe_runtime_params', []),
     $be_runtime_params = hiera('profile::cache::base::be_runtime_params', []),
+    $logstash_host = hiera('logstash_host', undef),
+    $logstash_syslog_port = hiera('logstash_syslog_port', undef),
 ) {
     # There is no better way to do this, so it can't be a class parameter. In 
fact,
     # I consider our requirement to make hiera calls parameters
@@ -81,9 +83,16 @@
     ###########################################################################
     # Analytics/Logging stuff
     ###########################################################################
+    if $logstash_host != undef and $logstash_syslog_port != undef {
+        $forward_syslog = "${logstash_host}:${logstash_syslog_port}"
+    } else {
+        $forward_syslog = ''
+    }
+
     class { '::varnish::logging':
-        cache_cluster => $cache_cluster,
-        statsd_host   => $statsd_host,
+        cache_cluster  => $cache_cluster,
+        statsd_host    => $statsd_host,
+        forward_syslog => $forward_syslog,
     }
 
     # auto-depool on shutdown + conditional one-shot auto-pool on start
diff --git a/modules/varnish/manifests/logging.pp 
b/modules/varnish/manifests/logging.pp
index 1c2da9a..ed532ab 100644
--- a/modules/varnish/manifests/logging.pp
+++ b/modules/varnish/manifests/logging.pp
@@ -4,14 +4,26 @@
 #
 # === Parameters
 #
-# [*cache_cluster*] The cache cluster we're part of.
+# [*cache_cluster*]
+#   The cache cluster we're part of.
 #
-# [*statsd_host*] The statsd host to send stats to.
+# [*statsd_host*]
+#   The statsd host to send stats to.
+#
+# [*forward_syslog*]
+#   Host and port to forward syslog events to. Disable forwarding by passing an
+#   empty string (default).
 #
 class varnish::logging(
     $cache_cluster,
     $statsd_host,
+    $forward_syslog='',
 ){
+    rsyslog::conf { 'varnish':
+        content  => template('varnish/rsyslog.conf.erb'),
+        priority => 80,
+    }
+
     # Client connection stats from the 'X-Connection-Properties'
     # header set by the SSL terminators.
     ::varnish::logging::xcps { 'xcps':
diff --git a/modules/varnish/templates/initscripts/varnish.systemd.erb 
b/modules/varnish/templates/initscripts/varnish.systemd.erb
index 0d093e8..18b9b27 100644
--- a/modules/varnish/templates/initscripts/varnish.systemd.erb
+++ b/modules/varnish/templates/initscripts/varnish.systemd.erb
@@ -25,6 +25,8 @@
 <% if @jemalloc_conf -%>
 Environment="MALLOC_CONF=<%= @jemalloc_conf %>"
 <% end -%>
+# rsyslog will see this in $programname
+SyslogIdentifier=varnish<%= @instancesuffix %>
 ExecReload=/usr/share/varnish/reload-vcl <%= @extraopts %> -q
 ExecStart=<%= @start_cmd_prefix %>/usr/sbin/varnishd \
 -P %t/%p.pid \
diff --git a/modules/varnish/templates/rsyslog.conf.erb 
b/modules/varnish/templates/rsyslog.conf.erb
new file mode 100644
index 0000000..fed1280
--- /dev/null
+++ b/modules/varnish/templates/rsyslog.conf.erb
@@ -0,0 +1,9 @@
+# rsyslog configuration for Varnish
+# This file is managed by Puppet
+
+<%- if @forward_syslog != "" -%>
+# Forward Varnish logs to logstash
+if $programname contains "varnish" then {
+    @<%= @forward_syslog %>
+}
+<%- end -%>

-- 
To view, visit https://gerrit.wikimedia.org/r/389515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63a3bea8cb22be9124f5de5866b47aeaed19001d
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ema <e...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to