Filippo Giunchedi has uploaded a new change for review.
https://gerrit.wikimedia.org/r/291710
Change subject: prometheus: add tools role
......................................................................
prometheus: add tools role
Change-Id: Ia5e1c50a64268422b5aabeffdf8ba23ca5f8b247
---
A modules/role/manifests/prometheus/tools.pp
1 file changed, 53 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/10/291710/1
diff --git a/modules/role/manifests/prometheus/tools.pp
b/modules/role/manifests/prometheus/tools.pp
new file mode 100644
index 0000000..09837a7
--- /dev/null
+++ b/modules/role/manifests/prometheus/tools.pp
@@ -0,0 +1,53 @@
+# == Class: role::prometheus::tools
+#
+# This role provides both project-wide host discovery/monitoring (via cron
+# prometheus-labs-targets) and kubernetes discovery/monitoring via Prometheus'
+# native k8s support.
+
+class role::prometheus::tools {
+ $bearer_token_file = '/srv/prometheus/tools/k8s.token'
+ $targets_file = '/srv/prometheus/tools/targets/node_project.yml'
+
+ prometheus::server { 'tools':
+ listen_address => '127.0.0.1:9902',
+ scrape_config_extra => [
+ {
+ 'job_name' => 'k8s',
+ 'bearer_token_file' => $bearer_token_file,
+ 'kubernetes_sd_configs' => [
+ {
+ 'api_servers' => hiera('k8s::master_host'),
+ 'bearer_token_file' => $bearer_token_file,
+ },
+ ]
+ }
+ ]
+ }
+
+ prometheus::web { 'tools':
+ proxy_pass => 'http://localhost:9902/tools',
+ }
+
+ # Ugly hack, ugh! (from modules/toollabs/manifests/kube2proxy.pp)
+ $users = hiera('k8s_users')
+ $client_token = inline_template("<%= @users.select { |u| u['name'] ==
'prometheus' }[0]['token'] %>")
+
+ file { $bearer_token_file:
+ ensure => present,
+ content => $client_token,
+ mode => '0400',
+ owner => 'prometheus',
+ group => 'prometheus',
+ require => Prometheus::Server['tools'],
+ }
+
+ include ::prometheus::scripts
+
+ cron { 'prometheus_tools_project_targets':
+ ensure => present,
+ command => "/usr/local/bin/prometheus-labs-targets >
${targets_file}.$$ && mv ${targets_file}.$$ ${targets_file}",
+ minute => '*/10',
+ hour => '*',
+ user => 'prometheus',
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/291710
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5e1c50a64268422b5aabeffdf8ba23ca5f8b247
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Filippo Giunchedi <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits