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|
end
jobs = {}
+junos_targets = []
snmp_targets = []
search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client|
}
end
+ Hash(client[:prometheus][:junos]).each do |instance, details|
+ junos_targets << {
+ :instance => instance,
+ :target => details[:address],
+ :address => client[:prometheus][:addresses]["junos"],
+ :labels => Array(details[:labels])
+ }
+ end
+
Hash(client[:prometheus][:snmp]).each do |instance, details|
snmp_targets << {
:instance => instance,
owner "root"
group "root"
mode "644"
- variables :jobs => jobs, :snmp_targets => snmp_targets, :certificates => certificates
+ variables :jobs => jobs, :junos_targets => junos_targets, :snmp_targets => snmp_targets, :certificates => certificates
end
template "/etc/prometheus/alert_rules.yml" do
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