]> git.openstreetmap.org Git - chef.git/commitdiff
Proxy requests to the prometheus and alertmanager web UIs
authorTom Hughes <tom@compton.nu>
Sun, 24 Jan 2021 11:59:16 +0000 (11:59 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 24 Jan 2021 12:05:17 +0000 (12:05 +0000)
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/apache.erb
cookbooks/prometheus/templates/default/default.alertmanager.erb [new file with mode: 0644]
cookbooks/prometheus/templates/default/default.prometheus.erb [new file with mode: 0644]
cookbooks/prometheus/templates/default/prometheus.yml.erb

index 9acc28671a06359d3d825f2c7ac2529b3dfd8dc4..d069cd8e7b9f166c28b9f3d8deaf7e8d89167ae2 100644 (file)
@@ -169,6 +169,13 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client
   end
 end
 
+template "/etc/default/prometheus" do
+  source "default.prometheus.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
 template "/etc/prometheus/prometheus.yml" do
   source "prometheus.yml.erb"
   owner "root"
@@ -179,9 +186,17 @@ end
 
 service "prometheus" do
   action [:enable, :start]
+  subscribes :restart, "template[/etc/default/prometheus]"
   subscribes :reload, "template[/etc/prometheus/prometheus.yml]"
 end
 
+template "/etc/default/prometheus-alertmanager" do
+  source "default.alertmanager.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
 template "/etc/prometheus/alertmanager.yml" do
   source "alertmanager.yml.erb"
   owner "root"
@@ -191,6 +206,7 @@ end
 
 service "prometheus-alertmanager" do
   action [:enable, :start]
+  subscribes :restart, "template[/etc/default/prometheus-alertmanager]"
   subscribes :reload, "template[/etc/prometheus/alertmanager.yml]"
 end
 
index b4c7c55ac7c0cab9a36af15d8b836a8b5408cfd3..00760ed436659ccba6466d2d0a53ab1b7ee1ef20 100644 (file)
@@ -23,6 +23,9 @@
        SSLCertificateFile /etc/ssl/certs/prometheus.openstreetmap.org.pem
        SSLCertificateKeyFile /etc/ssl/private/prometheus.openstreetmap.org.key
 
+       ProxyPass /prometheus http://localhost:9090/prometheus
+       Redirect 403 /alertmanager/api
+       ProxyPass /alertmanager http://localhost:9093/alertmanager
        ProxyPass / http://localhost:3000/
        ProxyPreserveHost on
 </VirtualHost>
diff --git a/cookbooks/prometheus/templates/default/default.alertmanager.erb b/cookbooks/prometheus/templates/default/default.alertmanager.erb
new file mode 100644 (file)
index 0000000..42d6e3a
--- /dev/null
@@ -0,0 +1,3 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+ARGS="--web.external-url=https://prometheus.openstreetmap.org/alertmanager"
diff --git a/cookbooks/prometheus/templates/default/default.prometheus.erb b/cookbooks/prometheus/templates/default/default.prometheus.erb
new file mode 100644 (file)
index 0000000..451faa7
--- /dev/null
@@ -0,0 +1,3 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+ARGS="--web.external-url=https://prometheus.openstreetmap.org/prometheus"
index b44654463a46473262c322809439a55037cb0a77..b7a3cf81ef49a54ceed3f91828af503164c7538b 100644 (file)
@@ -6,7 +6,8 @@ global:
 
 alerting:
   alertmanagers:
-    - static_configs:
+    - path_prefix: /alertmanager
+      static_configs:
         - targets:
             - localhost:9093
 
@@ -17,10 +18,12 @@ scrape_configs:
   - job_name: prometheus
     scrape_interval: 5s
     scrape_timeout: 5s
+    metrics_path: /prometheus/metrics
     static_configs:
       - targets:
           - localhost:9090
   - job_name: alertmanager
+    metrics_path: /alertmanager/metrics
     static_configs:
       - targets:
           - localhost:9093