Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render alerts file properly depending on prometheus version #253

Merged
merged 2 commits into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
prometheus::alerts { 'alert':
alerts => $alerts,
location => $config_dir,
version => $version,
}
$_rule_files = concat(["${config_dir}/alert.rules"], $extra_rule_files, $rule_files)
}
Expand Down
56 changes: 56 additions & 0 deletions spec/acceptance/prometheus_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,60 @@
it { is_expected.to be_listening.with('tcp6') }
end
end

describe 'prometheus with complex alerts and scrape configs' do
it 'is idempotent' do
pp = <<-EOS
class { 'prometheus::server':
version => '2.3.2',
alerts => {
'groups' => [
{
'name' => 'alert.rules',
'rules' => [
{
'alert' => 'InstanceDown',
'expr' => 'up == 0',
'for' => '5m',
'labels' => {
'severity' => 'page',
},
'annotations' => {
'summary' => 'Instance {{ $labels.instance }} down',
'description' => '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
}
}
]
}
]
},
scrape_configs => [
{
'job_name' => 'prometheus',
'scrape_interval' => '10s',
'scrape_timeout' => '10s',
'static_configs' => [
{
'targets' => [ 'localhost:9090' ],
'labels' => { 'alias' => 'Prometheus' }
}
]
}
]
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('prometheus') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe port(9090) do
it { is_expected.to be_listening.with('tcp6') }
end
end
end