Ema has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/390258 )
Change subject: varnish: log slow requests ...................................................................... varnish: log slow requests Introduce two services, varnish-frontend-slowreqs.service and varnish-slowreqs.service, responsible for logging slow requests going through varnish frontends and backends respectively. Requests are considered slow if no response is received within a certain number of seconds, configurable via profile::cache::base::log_slow_request_threshold (default 60.0s). Slow requests are logged to syslog using varnish-{frontend-,}slowreqs as the process name, set using the SyslogIdentifier systemd option. See systemd.exec(5) for the details. All logs with 'varnish' in the programname are sent to logstash by rsyslog (/etc/rsyslog.d/80-varnish.conf). Change-Id: Icb39030c74566cb8bbf7f6440951f3d223f39c62 --- M modules/profile/manifests/cache/base.pp M modules/varnish/manifests/common.pp M modules/varnish/manifests/instance.pp A modules/varnish/templates/initscripts/varnish-slowreqs.systemd.erb 4 files changed, 39 insertions(+), 4 deletions(-) Approvals: Ema: Looks good to me, approved jenkins-bot: Verified Filippo Giunchedi: Looks good to me, but someone else must approve diff --git a/modules/profile/manifests/cache/base.pp b/modules/profile/manifests/cache/base.pp index 07c89bd..373cf29 100644 --- a/modules/profile/manifests/cache/base.pp +++ b/modules/profile/manifests/cache/base.pp @@ -22,6 +22,7 @@ $be_runtime_params = hiera('profile::cache::base::be_runtime_params', []), $logstash_host = hiera('logstash_host', undef), $logstash_syslog_port = hiera('logstash_syslog_port', undef), + $log_slow_request_threshold = hiera('profile::cache::base::log_slow_request_threshold', '60.0'), ) { # 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 @@ -65,9 +66,10 @@ } class { '::varnish::common': - varnish_version => $varnish_version, - fe_runtime_params => $fe_runtime_params, - be_runtime_params => $be_runtime_params, + varnish_version => $varnish_version, + fe_runtime_params => $fe_runtime_params, + be_runtime_params => $be_runtime_params, + log_slow_request_threshold => $log_slow_request_threshold, } class { [ diff --git a/modules/varnish/manifests/common.pp b/modules/varnish/manifests/common.pp index f88237c..9550fdf 100644 --- a/modules/varnish/manifests/common.pp +++ b/modules/varnish/manifests/common.pp @@ -1,4 +1,9 @@ -class varnish::common($varnish_version=4, $fe_runtime_params=[], $be_runtime_params=[]) { +class varnish::common( + $varnish_version=4, + $fe_runtime_params=[], + $be_runtime_params=[], + $log_slow_request_threshold='60.0', +) { require ::varnish::packages # Frontend memory cache sizing diff --git a/modules/varnish/manifests/instance.pp b/modules/varnish/manifests/instance.pp index 1d615c8..8546942 100644 --- a/modules/varnish/manifests/instance.pp +++ b/modules/varnish/manifests/instance.pp @@ -168,6 +168,17 @@ }, } + # Log slow requests to syslog + systemd::service { "varnish${instancesuffix}-slowreqs": + ensure => present, + content => systemd_template('varnish-slowreqs'), + restart => true, + service_params => { + require => Service["varnish${instancesuffix}"], + enable => true, + }, + } + # This mechanism with the touch/rm conditionals in the pair of execs # below should ensure that reload-vcl failures are retried on # future puppet runs until they succeed. diff --git a/modules/varnish/templates/initscripts/varnish-slowreqs.systemd.erb b/modules/varnish/templates/initscripts/varnish-slowreqs.systemd.erb new file mode 100644 index 0000000..2386294 --- /dev/null +++ b/modules/varnish/templates/initscripts/varnish-slowreqs.systemd.erb @@ -0,0 +1,17 @@ +[Unit] +Description=Varnish <%= @inst %> Slow Requests +After=varnish<%= @instancesuffix %>.service +Requires=varnish<%= @instancesuffix %>.service + +[Service] +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=varnish<%= @instancesuffix %>-slowreqs +Restart=always +# Note the usage of the %% specifier here. +# See systemd.unit(5), section SPECIFIERS. +ExecStart=/usr/bin/varnishncsa <%= @extraopts %> -q 'ReqMethod ne "PURGE" and Timestamp:Resp[2] > <%= scope['::varnish::common::log_slow_request_threshold'] %>' -F '%{VSL:Timestamp:Resp}x %%r %%s' + +[Install] +WantedBy=multi-user.target + -- To view, visit https://gerrit.wikimedia.org/r/390258 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icb39030c74566cb8bbf7f6440951f3d223f39c62 Gerrit-PatchSet: 3 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ema <e...@wikimedia.org> Gerrit-Reviewer: BBlack <bbl...@wikimedia.org> Gerrit-Reviewer: Ema <e...@wikimedia.org> Gerrit-Reviewer: Filippo Giunchedi <fgiunch...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits