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

Change subject: WIP: varnish: prometheus equivalent of statsd metrics daemons
......................................................................

WIP: varnish: prometheus equivalent of statsd metrics daemons

Introduce the following mtail scripts:

- xcache.mtail (varnishxcache)
- resourceloader.mtail (varnishrls)
- media.mtail (varnishmedia)

Add and use mtail::script to install mtail scripts.

Bug: T177199
Change-Id: I31115573a5d7f43268eef3a1bcee92e18d5fa957
---
A modules/mtail/manifests/script.pp
A modules/varnish/files/mtail/media.mtail
A modules/varnish/files/mtail/resourceloader.mtail
A modules/varnish/files/mtail/xcache.mtail
M modules/varnish/manifests/logging/media.pp
M modules/varnish/manifests/logging/rls.pp
M modules/varnish/manifests/logging/xcache.pp
7 files changed, 70 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/43/394543/1

diff --git a/modules/mtail/manifests/script.pp 
b/modules/mtail/manifests/script.pp
new file mode 100644
index 0000000..b544b80
--- /dev/null
+++ b/modules/mtail/manifests/script.pp
@@ -0,0 +1,36 @@
+# Definition: mtail::script
+#
+# Install the given mtail script under the mtail scripts directory. There is no
+# need to notify any running mtail instance, changes are picked up by mtail
+# in a automatic fashion upon file modification.
+#
+# Parameters
+#   $source
+#       The file containing the mtail script to be installed (required).
+#   $destdir
+#       Destination directory. Defaults to /usr/local/share/mtail.
+#
+# Usage example:
+#   mtail::script { 'xcache':
+#       source => 'puppet:///modules/varnish/mtail/xcache.mtail',
+#   }
+#
+define mtail::script($source, $destdir='/usr/local/share/mtail') {
+    validate_string($source)
+    validate_absolute_path($destdir)
+
+    file { $destdir:
+        ensure => directory,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0444',
+    }
+
+    file { "${destdir}/${title}.mtail":
+        source  => $source,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        require => File[$destdir],
+    }
+}
diff --git a/modules/varnish/files/mtail/media.mtail 
b/modules/varnish/files/mtail/media.mtail
new file mode 100644
index 0000000..a84f184
--- /dev/null
+++ b/modules/varnish/files/mtail/media.mtail
@@ -0,0 +1,5 @@
+counter varnish_thumbnails by status
+
+/^url \/thumb\/.*\thttp_status (?P<http_status>.*)\tcache_control/ {
+    varnish_thumbnails[$http_status]++
+}
diff --git a/modules/varnish/files/mtail/resourceloader.mtail 
b/modules/varnish/files/mtail/resourceloader.mtail
new file mode 100644
index 0000000..0705e44
--- /dev/null
+++ b/modules/varnish/files/mtail/resourceloader.mtail
@@ -0,0 +1,7 @@
+counter varnish_resourceloader_inm
+
+/^url \/w\/load.php.*\tinm (?P<inm>.*)$/ {
+    $inm != "-" {
+        varnish_resourceloader_inm++
+    }
+}
diff --git a/modules/varnish/files/mtail/xcache.mtail 
b/modules/varnish/files/mtail/xcache.mtail
new file mode 100644
index 0000000..df4a197
--- /dev/null
+++ b/modules/varnish/files/mtail/xcache.mtail
@@ -0,0 +1,5 @@
+counter varnish_x_cache by x_cache
+
+/^.*\tcache_status (?P<x_cache>.*)\thttp_status/ {
+    varnish_x_cache[$x_cache]++
+}
diff --git a/modules/varnish/manifests/logging/media.pp 
b/modules/varnish/manifests/logging/media.pp
index a86e001..e9f7e33 100644
--- a/modules/varnish/manifests/logging/media.pp
+++ b/modules/varnish/manifests/logging/media.pp
@@ -1,7 +1,7 @@
 # == Define: varnish::logging::media
 #
 #  Accumulate browser cache hit ratio and total request volume statistics
-#  for Media requests and report to StatsD.
+#  for Media requests and report to StatsD. Expose metrics to prometheus.
 #
 # === Parameters
 #
@@ -42,4 +42,8 @@
         description  => 'Varnish traffic logger - varnishmedia',
         nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -a 
"/usr/local/bin/varnishmedia" -u root',
     }
+
+    mtail::script { 'media':
+        source => 'puppet:///modules/varnish/mtail/media.mtail',
+    }
 }
diff --git a/modules/varnish/manifests/logging/rls.pp 
b/modules/varnish/manifests/logging/rls.pp
index 9ee16e7..4c4629a 100644
--- a/modules/varnish/manifests/logging/rls.pp
+++ b/modules/varnish/manifests/logging/rls.pp
@@ -1,7 +1,8 @@
 # == Define: varnish::logging::rls
 #
-#  Accumulate browser cache hit ratio and total request volume statistics
-#  for ResourceLoader requests (/w/load.php) and report to StatsD.
+#  Accumulate browser cache hit ratio and total request volume statistics for
+#  ResourceLoader requests (/w/load.php) and report to StatsD. Expose metrics
+#  to prometheus.
 #
 # === Parameters
 #
@@ -43,4 +44,8 @@
         description  => 'Varnish traffic logger - varnishrls',
         nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -a 
"/usr/local/bin/varnishrls" -u root',
     }
+
+    mtail::script { 'resourceloader':
+        source => 'puppet:///modules/varnish/mtail/resourceloader.mtail',
+    }
 }
diff --git a/modules/varnish/manifests/logging/xcache.pp 
b/modules/varnish/manifests/logging/xcache.pp
index 2a8819b..d377943 100644
--- a/modules/varnish/manifests/logging/xcache.pp
+++ b/modules/varnish/manifests/logging/xcache.pp
@@ -1,5 +1,5 @@
 # == Define varnish::logging::xcache:
-# Logs X-Cache hit-related stats to statsd
+# Logs X-Cache hit-related stats to statsd. Expose counters to prometheus.
 #
 # === Parameters
 #
@@ -49,4 +49,8 @@
         description  => 'Varnish traffic logger - varnishxcache',
         nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -a 
"/usr/local/bin/varnishxcache" -u root',
     }
+
+    mtail::script { 'xcache':
+        source => 'puppet:///modules/varnish/mtail/xcache.mtail',
+    }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I31115573a5d7f43268eef3a1bcee92e18d5fa957
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ema <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to