Filippo Giunchedi has uploaded a new change for review. https://gerrit.wikimedia.org/r/290479
Change subject: prometheus: add nginx reverse proxy ...................................................................... prometheus: add nginx reverse proxy introduce prometheus::web to put nginx in front of multiple prometheus instances. Each instance can be accessed internally at http://localhost:<port> or externally at http://<address>/<instance_title>. Bug: T126785 Change-Id: I1025d613d5252b16b4ba1facc063c9897b5e9e86 --- A modules/prometheus/files/prometheus-nginx.conf A modules/prometheus/manifests/web.pp A modules/prometheus/templates/prometheus-nginx.erb M modules/role/manifests/prometheus/labs_project.pp A modules/role/manifests/prometheus/ops.pp 5 files changed, 63 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/79/290479/1 diff --git a/modules/prometheus/files/prometheus-nginx.conf b/modules/prometheus/files/prometheus-nginx.conf new file mode 100644 index 0000000..8a3617b --- /dev/null +++ b/modules/prometheus/files/prometheus-nginx.conf @@ -0,0 +1,10 @@ +server { + listen 80; + listen [::]:80; + + root /var/www/html; + + server_name prometheus.* prometheus-*.*; + + include /etc/prometheus-nginx/*.conf; +} diff --git a/modules/prometheus/manifests/web.pp b/modules/prometheus/manifests/web.pp new file mode 100644 index 0000000..88ff114 --- /dev/null +++ b/modules/prometheus/manifests/web.pp @@ -0,0 +1,32 @@ +# == Define prometheus::web +# +# Provision a reverse proxy with nginx towards a prometheus instance. + +define prometheus::web ( + $proxy_pass +) { + if !defined(File['/etc/prometheus-nginx']) { + file { '/etc/prometheus-nginx': + ensure => directory, + owner => 'root', + group => 'root', + mode => '0555', + } + } + + # Nginx configuration snippet with proxy pass. + file { "/etc/prometheus-nginx/${title}.conf": + ensure => file, + content => template('prometheus/prometheus-nginx.erb'), + mode => '0444', + owner => 'root', + group => 'root', + } + + # Single prometheus nginx site, will include /etc/prometheus-nginx/*.conf + if !defined(Nginx::Site['prometheus']) { + nginx::site{ 'prometheus': + source => 'puppet:///modules/prometheus/prometheus-nginx.conf', + } + } +} diff --git a/modules/prometheus/templates/prometheus-nginx.erb b/modules/prometheus/templates/prometheus-nginx.erb new file mode 100644 index 0000000..25e013a --- /dev/null +++ b/modules/prometheus/templates/prometheus-nginx.erb @@ -0,0 +1,8 @@ +# disable golang debugging from outside localhost +location /<%= @title %>/debug { + return 403; +} + +location /<%= @title %> { + proxy_pass <%= @proxy_pass %>; +} diff --git a/modules/role/manifests/prometheus/labs_project.pp b/modules/role/manifests/prometheus/labs_project.pp index deebf3f..293227a 100644 --- a/modules/role/manifests/prometheus/labs_project.pp +++ b/modules/role/manifests/prometheus/labs_project.pp @@ -11,6 +11,10 @@ listen_address => '127.0.0.1:9901' } + prometheus::web { 'labs': + proxy_pass => 'http://127.0.0.1:9901/labs', + } + $targets_file = '/srv/prometheus/labs/targets/node_project.yml' include ::prometheus::scripts diff --git a/modules/role/manifests/prometheus/ops.pp b/modules/role/manifests/prometheus/ops.pp new file mode 100644 index 0000000..da5d861 --- /dev/null +++ b/modules/role/manifests/prometheus/ops.pp @@ -0,0 +1,9 @@ +class role::prometheus::ops { + prometheus::server { 'ops': + listen_address => '127.0.0.1:9900', + } + + prometheus::web { 'ops': + proxy_pass => 'http://localhost:9900/ops', + } +} -- To view, visit https://gerrit.wikimedia.org/r/290479 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1025d613d5252b16b4ba1facc063c9897b5e9e86 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
