]> git.openstreetmap.org Git - chef.git/commitdiff
Add karma frontend for alertmanager
authorTom Hughes <tom@compton.nu>
Sun, 21 Nov 2021 09:57:23 +0000 (09:57 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 21 Nov 2021 09:57:23 +0000 (09:57 +0000)
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/apache.erb
cookbooks/prometheus/templates/default/karma.yml.erb [new file with mode: 0644]

index 675a206ec1f06613a4861dafcbe5c5a89ae8378b..2e3ab53ade82e05141d0145f53a79b0bda709e61 100644 (file)
@@ -37,6 +37,7 @@ cache_dir = Chef::Config[:file_cache_path]
 
 prometheus_version = "2.31.1"
 alertmanager_version = "0.23.0"
+karma_version = "0.93"
 
 directory "/opt/prometheus-server" do
   owner "root"
@@ -80,6 +81,23 @@ archive_file "#{cache_dir}/alertmanager.linux-amd64.tar.gz" do
   subscribes :extract, "remote_file[#{cache_dir}/alertmanager.linux-amd64.tar.gz]"
 end
 
+remote_file "#{cache_dir}/karma-linux-amd64.tar.gz" do
+  source "https://github.com/prymitive/karma/releases/download/v#{karma_version}/karma-linux-amd64.tar.gz"
+  owner "root"
+  group "root"
+  mode "644"
+  backup false
+end
+
+archive_file "#{cache_dir}/karma-linux-amd64.tar.gz" do
+  action :nothing
+  destination "/opt/prometheus-server/karma"
+  overwrite true
+  owner "root"
+  group "root"
+  subscribes :extract, "remote_file[#{cache_dir}/karma-linux-amd64.tar.gz]"
+end
+
 package %w[
   prometheus
   prometheus-alertmanager
@@ -311,6 +329,30 @@ template "/etc/prometheus/amtool.yml" do
   mode "644"
 end
 
+template "/etc/prometheus/karma.yml" do
+  source "karma.yml.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
+systemd_service "prometheus-karma" do
+  description "Alert dashboard for Prometheus Alertmanager"
+  user "prometheus"
+  exec_start "/opt/prometheus-server/karma/karma-linux-amd64 --config.file=/etc/prometheus/karma.yml"
+  private_tmp true
+  private_devices true
+  protect_system "full"
+  protect_home true
+  no_new_privileges true
+  restart "on-failure"
+end
+
+service "prometheus-karma" do
+  action [:enable, :start]
+  subscribes :reload, "template[/etc/prometheus/karma.yml]"
+end
+
 package "grafana-enterprise"
 
 template "/etc/grafana/grafana.ini" do
index edc1647af906fcbe20de0ea7e498bb82cf6338ae..629e409e26e38c6ff3fc0f8689735b9fc0143d4b 100644 (file)
        ProxyPass /prometheus http://localhost:9090/prometheus
        Redirect 403 /alertmanager/api
        ProxyPass /alertmanager http://localhost:9093/alertmanager
+       ProxyPass /karma http://localhost:8081/karma
        ProxyPass / http://localhost:3000/
        ProxyPreserveHost on
 
        <Location /alertmanager>
 <% @admin_hosts.each do |host| -%>
                Require ip <%= host %>
+<% end -%>
+       </Location>
+
+       <Location /karma>
+<% @admin_hosts.each do |host| -%>
+               Require ip <%= host %>
 <% end -%>
        </Location>
 </VirtualHost>
diff --git a/cookbooks/prometheus/templates/default/karma.yml.erb b/cookbooks/prometheus/templates/default/karma.yml.erb
new file mode 100644 (file)
index 0000000..cc61c6e
--- /dev/null
@@ -0,0 +1,21 @@
+karma:
+  name: OpenStreetMap
+alertmanager:
+  interval: 1m
+  servers:
+    - name: openstreetmap
+      uri: http://127.0.0.1:9093/alertmanager/
+      external_uri: https://prometheus.openstreetmap.org/alertmanager/
+      proxy: true
+listen:
+  port: 8081
+  prefix: /karma/
+filters:
+  default:
+    - "@state=active"
+labels:
+  color:
+    static:
+      - instance
+  strip:
+    - "@cluster"