Merge branch 'alertmanager-webhook' of kazu634/itamae into master
This commit is contained in:
commit
2efe201394
|
@ -0,0 +1,50 @@
|
||||||
|
alertmanager_webhook_url = ''
|
||||||
|
alertmanager_webhook_bin = ''
|
||||||
|
|
||||||
|
tag = ''
|
||||||
|
|
||||||
|
# Calculate the Download URL:
|
||||||
|
begin
|
||||||
|
require 'net/http'
|
||||||
|
|
||||||
|
uri = URI.parse('https://github.com/tomtom-international/alertmanager-webhook-logger/releases/latest')
|
||||||
|
|
||||||
|
Timeout.timeout(3) do
|
||||||
|
response = Net::HTTP.get_response(uri)
|
||||||
|
|
||||||
|
tag = $1 if response.body =~ %r{tag\/(\d+\.\d+)}
|
||||||
|
|
||||||
|
alertmanager_webhook_bin = "#{node['alertmanager_webhook']['prefix']}#{tag}#{node['alertmanager_webhook']['postfix']}"
|
||||||
|
|
||||||
|
alertmanager_webhook_url = "#{node['alertmanager_webhook']['url']}/#{tag}/#{alertmanager_webhook_bin}"
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
# Abort the chef client process:
|
||||||
|
raise 'Cannot connect to http://github.com.'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Download:
|
||||||
|
TMP = "/tmp/#{alertmanager_webhook_bin}"
|
||||||
|
|
||||||
|
execute "wget #{alertmanager_webhook_url} -O #{TMP}"
|
||||||
|
|
||||||
|
# Install:
|
||||||
|
directory node['alertmanager_webhook']['storage'] do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '755'
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "tar zxf #{TMP} -C #{node['alertmanager_webhook']['storage']}"
|
||||||
|
|
||||||
|
# Change Owner and Permissions:
|
||||||
|
file "#{node['alertmanager_webhook']['storage']}alertmanager-webhook-logger" do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '755'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Create Link
|
||||||
|
link "#{node['alertmanager_webhook']['location']}alertmanager-webhook-logger" do
|
||||||
|
to "#{node['alertmanager_webhook']['storage']}alertmanager-webhook-logger"
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Deploy `supervisor` config for `Alert Manager Webhook Logger`
|
||||||
|
remote_file '/etc/supervisor/conf.d/alertmanager_webhook_logger.conf' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[supervisor]'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Restart the `supervisor`:
|
||||||
|
service 'supervisor' do
|
||||||
|
action :nothing
|
||||||
|
end
|
||||||
|
|
|
@ -31,4 +31,11 @@ node.reverse_merge!({
|
||||||
'storage' => '/opt/prometheus/',
|
'storage' => '/opt/prometheus/',
|
||||||
'location' => '/usr/local/bin/'
|
'location' => '/usr/local/bin/'
|
||||||
},
|
},
|
||||||
|
'alertmanager_webhook' => {
|
||||||
|
'url' => 'https://github.com/tomtom-international/alertmanager-webhook-logger/releases/download/',
|
||||||
|
'prefix' => 'alertmanager-webhook-logger-',
|
||||||
|
'postfix' => '.tar.gz',
|
||||||
|
'storage' => '/opt/prometheus/',
|
||||||
|
'location' => '/usr/local/bin/'
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,6 +8,9 @@ if node['prometheus']['manager']
|
||||||
|
|
||||||
include_recipe './alertmanager_install.rb'
|
include_recipe './alertmanager_install.rb'
|
||||||
include_recipe './alertmanager_setup.rb'
|
include_recipe './alertmanager_setup.rb'
|
||||||
|
|
||||||
|
include_recipe './alertmanager_webhook_install.rb'
|
||||||
|
include_recipe './alertmanager_webhook_setup.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Install the node_exporter here:
|
# Install the node_exporter here:
|
||||||
|
|
|
@ -15,3 +15,7 @@ receivers:
|
||||||
title: "{{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
|
title: "{{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
|
||||||
text: "{{ range .Alerts }}{{ .Annotations.description }}\n{{ end }}"
|
text: "{{ range .Alerts }}{{ .Annotations.description }}\n{{ end }}"
|
||||||
send_resolved: true
|
send_resolved: true
|
||||||
|
|
||||||
|
webhook_configs:
|
||||||
|
- send_resolved: true
|
||||||
|
url: 'http://localhost:6725'
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[program:alertmanager-webhook-logger]
|
||||||
|
command=/usr/local/bin/alertmanager-webhook-logger
|
||||||
|
stdout_logfile=/var/log/supervisor/alertmanager-webhook-logger.log
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile_maxbytes=1MB
|
||||||
|
stdout_logfile_backups=5
|
||||||
|
autorestart=true
|
Loading…
Reference in New Issue