Skip to content

Commit ea9b865

Browse files
author
Nick Apostolakis
committed
[CBD-98] adding a template configuration file that can be used to start everything
1 parent ba649b0 commit ea9b865

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

attributes/default.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,20 @@
211211
default['prometheus']['alertmanager']['git_revision'] = node['prometheus']['alertmanager']['version']
212212

213213
# Alertmanager configuration file name.
214-
default['prometheus']['alertmanager']['config.file'] = "#{node['prometheus']['dir']}/alertmanager/simple.yml"
214+
default['prometheus']['alertmanager']['config.file'] = "#{node['prometheus']['dir']}/alertmanager/alertmanager.config.yml"
215215

216216
# Alertmanager configuration chef template name.
217217
default['prometheus']['alertmanager']['config_cookbook_name'] = 'prometheus'
218218

219219
# Alertmanager custom configuration cookbook. Use this if you'd like to bypass the
220220
# default prometheus cookbook Alertmanager configuration template and implement your own
221221
# templates and recipes to configure Alertmanager.
222-
default['prometheus']['alertmanager']['config_template_name'] = 'alertmanager.conf.erb'
222+
default['prometheus']['alertmanager']['config_template_name'] = 'alertmanager.config.yml.erb'
223+
224+
# Smarthost to use when Alertmanager notifies using email
225+
default['prometheus']['alertmanager']['smarthost'] = 'localhost:25'
226+
# Mail from to use when Alertmanager notifies using email
227+
default['prometheus']['alertmanager']['mailfrom'] = 'alertmanager@example.org'
223228

224229
# Service key to use when Alertmanager notifies Pager Duty
225230
default['prometheus']['alertmanager']['pagerduty_service_key'] = 'supersecretapikey'

recipes/alertmanager.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@
5555
action :put
5656
end
5757

58+
log 'creating a sample configuration file if it does not exist'
59+
template node['prometheus']['alertmanager']['config.file'] do
60+
cookbook node['prometheus']['alertmanager']['config_cookbook_name']
61+
source node['prometheus']['alertmanager']['config_template_name']
62+
mode 0644
63+
owner node['prometheus']['user']
64+
group node['prometheus']['group']
65+
not_if do ::File.exists?("#{node['prometheus']['alertmanager']['config.file']}") end
66+
end
67+
68+
5869
log 'setting up alertmanager service'
5970
alertmanager_command="#{node['prometheus']['alertmanager']['binary']} -config.file=#{node['prometheus']['alertmanager']['config.file']}"
6071
supervisor_service "alertmanager" do

templates/default/alertmanager.conf.erb

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)