environment "STATUSCAKE_APIKEY" => tokens["statuscake"]
end
+template "/etc/prometheus/cloudwatch.yml" do
+ source "cloudwatch.yml.erb"
+ owner "root"
+ group "root"
+ mode "644"
+end
+
+prometheus_exporter "cloudwatch" do
+ address "127.0.0.1"
+ port 5000
+ listen_switch "listen-address"
+ options "--config.file=/etc/prometheus/cloudwatch.yml"
+ environment "AWS_ACCESS_KEY_ID" => "AKIASQUXHPE7JHG37EA6",
+ "AWS_SECRET_ACCESS_KEY" => tokens["cloudwatch"]
+end
+
cache_dir = Chef::Config[:file_cache_path]
prometheus_version = "2.45.0"
mode "755"
end
-remote_file "#{cache_dir}/prometheus.linux-amd64.tar.gz" do
- source "https://github.com/prometheus/prometheus/releases/download/v#{prometheus_version}/prometheus-#{prometheus_version}.linux-amd64.tar.gz"
+prometheus_arch = if arm?
+ "arm64"
+ else
+ "amd64"
+ end
+
+remote_file "#{cache_dir}/prometheus.linux.tar.gz" do
+ source "https://github.com/prometheus/prometheus/releases/download/v#{prometheus_version}/prometheus-#{prometheus_version}.linux-#{prometheus_arch}.tar.gz"
owner "root"
group "root"
mode "644"
backup false
end
-archive_file "#{cache_dir}/prometheus.linux-amd64.tar.gz" do
+archive_file "#{cache_dir}/prometheus.linux.tar.gz" do
action :nothing
destination "/opt/prometheus-server/prometheus"
overwrite true
strip_components 1
owner "root"
group "root"
- subscribes :extract, "remote_file[#{cache_dir}/prometheus.linux-amd64.tar.gz]", :immediately
+ subscribes :extract, "remote_file[#{cache_dir}/prometheus.linux.tar.gz]", :immediately
end
-remote_file "#{cache_dir}/alertmanager.linux-amd64.tar.gz" do
- source "https://github.com/prometheus/alertmanager/releases/download/v#{alertmanager_version}/alertmanager-#{alertmanager_version}.linux-amd64.tar.gz"
+remote_file "#{cache_dir}/alertmanager.linux.tar.gz" do
+ source "https://github.com/prometheus/alertmanager/releases/download/v#{alertmanager_version}/alertmanager-#{alertmanager_version}.linux-#{prometheus_arch}.tar.gz"
owner "root"
group "root"
mode "644"
backup false
end
-archive_file "#{cache_dir}/alertmanager.linux-amd64.tar.gz" do
+archive_file "#{cache_dir}/alertmanager.linux.tar.gz" do
action :nothing
destination "/opt/prometheus-server/alertmanager"
overwrite true
strip_components 1
owner "root"
group "root"
- subscribes :extract, "remote_file[#{cache_dir}/alertmanager.linux-amd64.tar.gz]", :immediately
+ subscribes :extract, "remote_file[#{cache_dir}/alertmanager.linux.tar.gz]", :immediately
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"
+remote_file "#{cache_dir}/karma-linux.tar.gz" do
+ source "https://github.com/prymitive/karma/releases/download/v#{karma_version}/karma-linux-#{prometheus_arch}.tar.gz"
owner "root"
group "root"
mode "644"
backup false
end
-archive_file "#{cache_dir}/karma-linux-amd64.tar.gz" do
+archive_file "#{cache_dir}/karma-linux.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]", :immediately
+ subscribes :extract, "remote_file[#{cache_dir}/karma-linux.tar.gz]", :immediately
end
search(:node, "roles:gateway") do |gateway|
action [:enable, :start]
subscribes :reload, "template[/etc/prometheus/prometheus.yml]"
subscribes :reload, "template[/etc/prometheus/alert_rules.yml]"
- subscribes :restart, "archive_file[#{cache_dir}/prometheus.linux-amd64.tar.gz]"
+ subscribes :restart, "archive_file[#{cache_dir}/prometheus.linux.tar.gz]"
end
systemd_service "prometheus-alertmanager" do
action [:enable, :start]
subscribes :reload, "template[/etc/prometheus/alertmanager.yml]"
subscribes :restart, "systemd_service[prometheus-alertmanager]"
- subscribes :restart, "archive_file[#{cache_dir}/alertmanager.linux-amd64.tar.gz]"
+ subscribes :restart, "archive_file[#{cache_dir}/alertmanager.linux.tar.gz]"
end
directory "/etc/amtool" do
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"
+ exec_start "/opt/prometheus-server/karma/karma-linux-#{prometheus_arch} --config.file=/etc/prometheus/karma.yml"
sandbox :enable_network => true
restart "on-failure"
end
service "prometheus-karma" do
action [:enable, :start]
subscribes :restart, "template[/etc/prometheus/karma.yml]"
- subscribes :restart, "archive_file[#{cache_dir}/karma-linux-amd64.tar.gz]"
+ subscribes :restart, "archive_file[#{cache_dir}/karma-linux.tar.gz]"
subscribes :restart, "systemd_service[prometheus-karma]"
end