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

Change subject: [WIP]prometheus: Convert mysqld-exporter into multi-instance
......................................................................

[WIP]prometheus: Convert mysqld-exporter into multi-instance

We need to monitor several independent mysql instances on the same
host. Add an additional resource that actually can be duplicated
so that more than one instance can be run at the same time.

This is still work in progress, but uploaded so it can be discussed
before more refactoring is done. Needs architecture feedback.

Bug: T169514
Change-Id: I664f04c7b026aedf32a1ef1ec648fea81dd47436
---
A modules/prometheus/manifests/mysqld_exporter_multiinstance.pp
1 file changed, 65 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/96/364396/1

diff --git a/modules/prometheus/manifests/mysqld_exporter_multiinstance.pp 
b/modules/prometheus/manifests/mysqld_exporter_multiinstance.pp
new file mode 100644
index 0000000..7094872
--- /dev/null
+++ b/modules/prometheus/manifests/mysqld_exporter_multiinstance.pp
@@ -0,0 +1,65 @@
+# == Define: prometheus::mysqld_exporter
+#
+# Prometheus exporter for MySQL server metrics. The exporter is most effective
+# when ran alongside the MySQL server to be monitored, connecting via a local
+# UNIX socket is supported.
+#
+# = Parameters
+#
+# [*client_socket*]
+#   The socket to connect to.
+#
+# [*client_user*]
+#   MySQL user
+#
+# [*client_password*]
+#   MySQL password
+#
+# [*arguments*]
+#   Additional command line arguments for prometheus-mysqld-exporter.
+
+define prometheus::mysqld_exporter (
+    $client_socket = '/tmp/mysql.sock',
+    $client_user = 'prometheus',
+    $client_password = '',
+    $port = 9104,
+    $arguments = '',
+) {
+    #require_package('prometheus-mysqld-exporter')
+    #
+    #file { '/var/lib/prometheus':
+    #    ensure => directory,
+    #    mode   => '0550',
+    #    owner  => 'prometheus',
+    #    group  => 'prometheus',
+    #}
+
+    # default .my.cnf location (i.e. $HOME/.my.cnf)
+    file { "/var/lib/prometheus/{$title}.my.cnf":
+        ensure  => present,
+        mode    => '0400',
+        owner   => 'prometheus',
+        group   => 'prometheus',
+        content => template('prometheus/mysqld_exporter.cnf.erb'),
+        require => [
+          Package['prometheus-mysqld-exporter'],
+          File['/var/lib/prometheus'],
+        ],
+        notify  => Service['prometheus-mysqld-exporter@{$title}'],
+    }
+
+    #file { '/etc/default/prometheus-mysqld-exporter':
+    #    ensure  => present,
+    #    mode    => '0444',
+    #    owner   => 'root',
+    #    group   => 'root',
+    #    content => "ARGS=\"${arguments}\"",
+    #    notify  => Service['prometheus-mysqld-exporter'],
+    #}
+
+    service { "prometheus-mysqld-exporter@{$title}":
+        ensure  => running,
+        require => [Package['prometheus-mysqld-exporter'],
+                    File['/var/lib/prometheus/{$title}.my.cnf']],
+    }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I664f04c7b026aedf32a1ef1ec648fea81dd47436
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Jcrespo <jcre...@wikimedia.org>

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

Reply via email to