Yuvipanda has submitted this change and it was merged.

Change subject: prometheus: Add blackbox exporter role/class
......................................................................


prometheus: Add blackbox exporter role/class

https://wikitech.wikimedia.org/wiki/Prometheus/Black_box_exporter
explains how to build the deb. Deb is currently available only
in the tools project

Change-Id: I9050ff361ecf4dcc432bab2c0b5cb3627c6bfbff
---
A modules/prometheus/manifests/blackbox_exporter.pp
A modules/prometheus/templates/blackbox_exporter.yml.erb
A 
modules/prometheus/templates/initscripts/prometheus-blackbox-exporter.systemd.erb
A modules/role/manifests/prometheus/blackbox_exporter.pp
M modules/role/manifests/prometheus/tools.pp
5 files changed, 62 insertions(+), 0 deletions(-)

Approvals:
  Yuvipanda: Verified; Looks good to me, approved



diff --git a/modules/prometheus/manifests/blackbox_exporter.pp 
b/modules/prometheus/manifests/blackbox_exporter.pp
new file mode 100644
index 0000000..fa7446f
--- /dev/null
+++ b/modules/prometheus/manifests/blackbox_exporter.pp
@@ -0,0 +1,27 @@
+# Prometheus black box metrics exporter. See also
+# https://github.com/prometheus/blackbox_exporter
+#
+# This does 'active' checks over TCP / UDP / ICMP / HTTP / DNS
+# and reports status to the prometheus scraper
+
+class prometheus::blackbox_exporter{
+    requires_os('debian >= jessie')
+
+    require_package('prometheus-blackbox-exporter')
+
+    file { '/etc/prometheus-blackbox_exporter.yml':
+        ensure  => present,
+        mode    => '0444',
+        owner   => 'root',
+        group   => 'root',
+        content => template('prometheus/blackbox_exporter.yml.erb'),
+        notify  => Service['prometheus-blackbox-exporter'],
+    }
+
+    base::service_unit { 'prometheus-blackbox-exporter':
+        ensure  => present,
+        refresh => true,
+        systemd => true,
+        require => Package['prometheus-blackbox-exporter'],
+    }
+}
diff --git a/modules/prometheus/templates/blackbox_exporter.yml.erb 
b/modules/prometheus/templates/blackbox_exporter.yml.erb
new file mode 100644
index 0000000..55b6d5a
--- /dev/null
+++ b/modules/prometheus/templates/blackbox_exporter.yml.erb
@@ -0,0 +1,13 @@
+modules:
+  tcp_connect:
+    prober: tcp
+    timeout: 5s
+  ssh_banner:
+    prober: tcp
+    timeout: 5s
+    tcp:
+      query_response:
+      - expect: "^SSH-2.0-"
+  icmp:
+    prober: icmp
+    timeout: 5s
diff --git 
a/modules/prometheus/templates/initscripts/prometheus-blackbox-exporter.systemd.erb
 
b/modules/prometheus/templates/initscripts/prometheus-blackbox-exporter.systemd.erb
new file mode 100644
index 0000000..2f35925
--- /dev/null
+++ 
b/modules/prometheus/templates/initscripts/prometheus-blackbox-exporter.systemd.erb
@@ -0,0 +1,7 @@
+[Unit]
+Description=prometheus-blackbox-exporter
+
+[Service]
+User=prometheus
+ExecStart=/usr/bin/blackbox_exporter -config.file 
/etc/prometheus-blackbox_exporter.yml
+Restart=on-failure
diff --git a/modules/role/manifests/prometheus/blackbox_exporter.pp 
b/modules/role/manifests/prometheus/blackbox_exporter.pp
new file mode 100644
index 0000000..6d54120
--- /dev/null
+++ b/modules/role/manifests/prometheus/blackbox_exporter.pp
@@ -0,0 +1,14 @@
+# == Class: role::prometheus::blackbox_exporter
+#
+# Role to provision prometheus blackbox / active checks exporter. See
+# https://github.com/prometheus/blackbox_exporter and the module's 
documentation.
+
+class role::prometheus::blackbox_exporter {
+    include ::prometheus::blackbox_exporter
+
+    ferm::service { 'prometheus-blackbox-exporter':
+        proto  => 'tcp',
+        port   => '9115',
+        srange => '$DOMAIN_NETWORKS',
+    }
+}
diff --git a/modules/role/manifests/prometheus/tools.pp 
b/modules/role/manifests/prometheus/tools.pp
index fd6afd0..f254ba3 100644
--- a/modules/role/manifests/prometheus/tools.pp
+++ b/modules/role/manifests/prometheus/tools.pp
@@ -59,6 +59,7 @@
         require => Prometheus::Server['tools'],
     }
 
+    include ::role::prometheus::blackbox_exporter
     include ::prometheus::scripts
 
     $targets_path = '/srv/prometheus/tools/targets'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9050ff361ecf4dcc432bab2c0b5cb3627c6bfbff
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yuvipanda <yuvipa...@wikimedia.org>
Gerrit-Reviewer: Yuvipanda <yuvipa...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to