prometheus_version = "2.31.1"
alertmanager_version = "0.23.0"
+karma_version = "0.93"
directory "/opt/prometheus-server" do
owner "root"
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
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
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>