forked from elijah/chef-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recipe for deploying Alertmanager
- Loading branch information
Paul Magrath
committed
Aug 5, 2015
1 parent
21141d6
commit 921e933
Showing
5 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# | ||
# Cookbook Name:: prometheus | ||
# Recipe:: alertmanager | ||
# | ||
# Author: Paul Magrath <paul@paulmagrath.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
include_recipe 'build-essential::default' | ||
|
||
user node['prometheus']['user'] do | ||
system true | ||
shell '/bin/false' | ||
home node['prometheus']['dir'] | ||
not_if { node['prometheus']['use_existing_user'] == true || node['prometheus']['user'] == 'root' } | ||
end | ||
|
||
directory node['prometheus']['dir'] do | ||
owner node['prometheus']['user'] | ||
group node['prometheus']['group'] | ||
mode '0755' | ||
recursive true | ||
end | ||
|
||
directory node['prometheus']['log_dir'] do | ||
owner node['prometheus']['user'] | ||
group node['prometheus']['group'] | ||
mode '0755' | ||
recursive true | ||
end | ||
|
||
# -- Write our Config -- # | ||
|
||
template node['prometheus']['alertmanager']['config.file'] do | ||
cookbook node['prometheus']['alertmanager']['config_cookbook_name'] | ||
source node['prometheus']['alertmanager']['config_template_name'] | ||
mode 0644 | ||
owner node['prometheus']['user'] | ||
group node['prometheus']['group'] | ||
notifies :restart, 'service[alertmanager]' | ||
end | ||
|
||
# -- Do the install -- # | ||
|
||
# These packages are needed go build | ||
%w( curl git-core mercurial gzip sed ).each do |pkg| | ||
package pkg | ||
end | ||
|
||
git "#{Chef::Config[:file_cache_path]}/alertmanager-#{node['prometheus']['alertmanager']['version']}" do | ||
repository node['prometheus']['alertmanager']['git_repository'] | ||
revision node['prometheus']['alertmanager']['git_revision'] | ||
action :checkout | ||
end | ||
|
||
bash 'compile_alertmanager_source' do | ||
cwd "#{Chef::Config[:file_cache_path]}/alertmanager-#{node['prometheus']['alertmanager']['version']}" | ||
code <<-EOH | ||
make && | ||
mv alertmanager #{node['prometheus']['dir']} | ||
EOH | ||
|
||
notifies :restart, 'service[alertmanager]' | ||
end | ||
|
||
template '/etc/init/alertmanager.conf' do | ||
source 'upstart/alertmanager.service.erb' | ||
mode 0644 | ||
notifies :restart, 'service[alertmanager]', :delayed | ||
end | ||
|
||
service 'alertmanager' do | ||
provider Chef::Provider::Service::Upstart | ||
action [:enable, :start] | ||
end | ||
|
||
# rubocop:disable Style/HashSyntax | ||
service 'alertmanager' do | ||
supports :status => true, :restart => true | ||
end | ||
# rubocop:enable Style/HashSyntax | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
notification_config { | ||
name: "alertmanager_pagerduty" | ||
pagerduty_config: { | ||
service_key: "<%= node['prometheus']['alertmanager']['pagerduty_service_key'] %>" | ||
} | ||
} | ||
|
||
notification_config { | ||
name: "alertmanager_hipchat" | ||
hipchat_config: { | ||
auth_token: "<%= node['prometheus']['alertmanager']['hipchat_auth_token'] %>" | ||
room_id: <%= node['prometheus']['alertmanager']['hipchat_room_id'] %> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
description "Prometheus Alertmanager" | ||
start on (local-filesystems and net-device-up IFACE!=lo) | ||
stop on runlevel [016] | ||
|
||
respawn | ||
env GOMAXPROCS=<%= node['cpu']['total'] %> | ||
setuid <%= node['prometheus']['user'] %> | ||
setgid <%= node['prometheus']['user'] %> | ||
|
||
script | ||
exec >> "<%= node['prometheus']['log_dir'] %>/alertmanager.log" | ||
exec 2>&1 | ||
exec <%= node['prometheus']['alertmanager']['binary'] %> -config.file=<%= node['prometheus']['alertmanager']['config.file'] %> | ||
end script |