Skip to content

Commit 40c18b3

Browse files
author
Nick Apostolakis
committed
[CBD-98] adding an alert manager test
1 parent ea9b865 commit 40c18b3

File tree

3 files changed

+129
-5
lines changed

3 files changed

+129
-5
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
global:
2+
# The smarthost and SMTP sender used for mail notifications.
3+
smtp_smarthost: '<%= node['prometheus']['alertmanager']['smarthost'] %>'
4+
smtp_from: '<%= node['prometheus']['alertmanager']['mailfrom'] %>'
5+
# The auth token for Hipchat.
6+
hipchat_auth_token: '1234556789'
7+
# Alternative host for Hipchat.
8+
hipchat_url: 'https://hipchat.foobar.org/'
9+
10+
# The directory from which notification templates are read.
11+
templates:
12+
- '/etc/alertmanager/template/*.tmpl'
13+
14+
# The root route on which each incoming alert enters.
15+
route:
16+
# The labels by which incoming alerts are grouped together. For example,
17+
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
18+
# be batched into a single group.
19+
group_by: ['alertname', 'cluster', 'service']
20+
21+
# When a new group of alerts is created by an incoming alert, wait at
22+
# least 'group_wait' to send the initial notification.
23+
# This way ensures that you get multiple alerts for the same group that start
24+
# firing shortly after another are batched together on the first
25+
# notification.
26+
group_wait: 30s
27+
28+
# When the first notification was sent, wait 'group_interval' to send a betch
29+
# of new alerts that started firing for that group.
30+
group_interval: 5m
31+
32+
# If an alert has successfully been sent, wait 'repeat_interval' to
33+
# resend them.
34+
repeat_interval: 3h
35+
36+
# A default receiver
37+
receiver: team-X-mails
38+
39+
# All the above attributes are inherited by all child routes and can
40+
# overwritten on each.
41+
42+
# The child route trees.
43+
routes:
44+
# This routes performs a regular expression match on alert labels to
45+
# catch alerts that are related to a list of services.
46+
- match_re:
47+
service: ^(foo1|foo2|baz)$
48+
receiver: team-X-mails
49+
# The service has a sub-route for critical alerts, any alerts
50+
# that do not match, i.e. severity != critical, fall-back to the
51+
# parent node and are sent to 'team-X-mails'
52+
routes:
53+
- match:
54+
severity: critical
55+
receiver: team-X-pager
56+
- match:
57+
service: files
58+
receiver: team-Y-mails
59+
60+
routes:
61+
- match:
62+
severity: critical
63+
receiver: team-Y-pager
64+
65+
# This route handles all alerts coming from a database service. If there's
66+
# no team to handle it, it defaults to the DB team.
67+
- match:
68+
service: database
69+
receiver: team-DB-pager
70+
# Also group alerts by affected database.
71+
group_by: [alertname, cluster, database]
72+
routes:
73+
- match:
74+
owner: team-X
75+
receiver: team-X-pager
76+
- match:
77+
owner: team-Y
78+
receiver: team-Y-pager
79+
80+
81+
# Inhibition rules allow to mute a set of alerts given that another alert is
82+
# firing.
83+
# We use this to mute any warning-level notifications if the same alert is
84+
# already critical.
85+
inhibit_rules:
86+
- source_match:
87+
severity: 'critical'
88+
target_match:
89+
severity: 'warning'
90+
# Apply inhibition if the alertname is the same.
91+
equal: ['alertname', 'cluster', 'service']
92+
93+
94+
receivers:
95+
- name: 'team-X-mails'
96+
email_configs:
97+
- to: 'team-X+alerts@example.org'
98+
99+
- name: 'team-X-pager'
100+
email_configs:
101+
- to: 'team-X+alerts-critical@example.org'
102+
pagerduty_configs:
103+
- service_key: <team-X-key>
104+
- name: 'team-Y-mails'
105+
email_configs:
106+
- to: 'team-Y+alerts@example.org'
107+
108+
- name: 'team-Y-pager'
109+
pagerduty_configs:
110+
- service_key: <team-Y-key>
111+
112+
- name: 'team-DB-pager'
113+
pagerduty_configs:
114+
- service_key: <team-DB-key>
115+
- name: 'team-X-hipchat'
116+
hipchat_configs:
117+
- auth_token: <auth_token>
118+
room_id: 85
119+
message_format: html
120+
notify: true
121+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require_relative '../../../kitchen/data/spec_helper'
2+
3+
describe service('alertmanager') do
4+
it { should be_running.under('supervisor') }
5+
end
6+

test/integration/default/serverspec/source_spec.rb renamed to test/integration/default/serverspec/prometheus-server_spec.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
require_relative '../../../kitchen/data/spec_helper'
22

3-
describe 'prometheus service' do
4-
describe service('prometheus') do
5-
it { should be_running }
6-
end
7-
3+
describe service('prometheus') do
4+
it { should be_running.under('supervisor') }
85
describe port(9090) do
96
it { should be_listening }
107
end

0 commit comments

Comments
 (0)