]> git.openstreetmap.org Git - chef.git/commitdiff
Configure prometheus alert manager
authorTom Hughes <tom@compton.nu>
Wed, 20 Jan 2021 19:03:36 +0000 (19:03 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 20 Jan 2021 19:17:05 +0000 (19:17 +0000)
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/alertmanager.yml.erb [new file with mode: 0644]
roles/mail.rb
test/integration/prometheus-server/serverspec/alertmanager_spec.rb [new file with mode: 0644]

index 571714c50047f2486b215aa9466dace98c322e4e..9acc28671a06359d3d825f2c7ac2529b3dfd8dc4 100644 (file)
@@ -32,7 +32,10 @@ prometheus_exporter "fastly" do
   environment "FASTLY_API_TOKEN" => tokens["fastly"]
 end
 
-package "prometheus"
+package %w[
+  prometheus
+  prometheus-alertmanager
+]
 
 promscale_version = "0.1.4"
 
@@ -179,6 +182,18 @@ service "prometheus" do
   subscribes :reload, "template[/etc/prometheus/prometheus.yml]"
 end
 
+template "/etc/prometheus/alertmanager.yml" do
+  source "alertmanager.yml.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
+service "prometheus-alertmanager" do
+  action [:enable, :start]
+  subscribes :reload, "template[/etc/prometheus/alertmanager.yml]"
+end
+
 package "grafana-enterprise"
 
 template "/etc/grafana/grafana.ini" do
diff --git a/cookbooks/prometheus/templates/default/alertmanager.yml.erb b/cookbooks/prometheus/templates/default/alertmanager.yml.erb
new file mode 100644 (file)
index 0000000..4df70fd
--- /dev/null
@@ -0,0 +1,23 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+global:
+  smtp_smarthost: localhost:25
+  smtp_from: prometheus@openstreetmap.org
+
+templates:
+  - /etc/prometheus/alertmanager_templates/*.tmpl
+
+route:
+  group_by:
+    - service
+  group_wait: 30s
+  group_interval: 5m
+  repeat_interval: 3h
+  receiver: admins-email
+
+inhibit_rules:
+
+receivers:
+  - name: admins-email
+    email_configs:
+      - to: admins@openstreetmap.org
index 660bb9f2f195e7466cf75293a12325cdfff8eb45..5783e1bda2f5ae2c1e793b94e9d4d823f317b58f 100644 (file)
@@ -58,6 +58,7 @@ default_attributes(
       "rails" => "root",
       "trac" => "root",
       "munin" => "root",
+      "prometheus" => "root",
       "www-data" => "root",
       "osmbackup" => "root",
       "noreply" => "/dev/null",
diff --git a/test/integration/prometheus-server/serverspec/alertmanager_spec.rb b/test/integration/prometheus-server/serverspec/alertmanager_spec.rb
new file mode 100644 (file)
index 0000000..cdad783
--- /dev/null
@@ -0,0 +1,17 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("prometheus-alertmanager") do
+  it { should be_installed }
+end
+
+describe service("prometheus-alertmanager") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(9093) do
+  it { should be_listening.with("tcp6") }
+end