From 2349bfcb515321fc28e059f63e6e764cc3ee019a Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 16 Jul 2018 14:18:17 +1000 Subject: [PATCH 1/6] allow 'prometheus::rule_files' definition to be included when building a list of rule files from data in prometheus::alerts and prometheus::extra_alerts --- manifests/server.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/server.pp b/manifests/server.pp index dcb8a196b..335db1609 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -78,10 +78,10 @@ alerts => $alerts, location => $config_dir, } - $_rule_files = concat(["${config_dir}/alert.rules"], $extra_rule_files) + $_rule_files = concat(["${config_dir}/alert.rules"], $extra_rule_files, $rule_files) } else { - $_rule_files = $extra_rule_files + $_rule_files = concat($extra_rule_files, $rule_files) } contain prometheus::install contain prometheus::config From cdaeb68abe37790dcd4b592090e345b8e29e1f7d Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 16 Jul 2018 14:52:45 +1000 Subject: [PATCH 2/6] Add string as it appears in data/default.yaml to the fixtures for prometheus1 and 2 . I am not sure if prometheus1 is even covered, and confused that what looks like variable interpolation is going right through to File[/etc/prometheus/prometheus.yaml] as literal --- spec/fixtures/files/prometheus1.yaml | 3 ++- spec/fixtures/files/prometheus2.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/files/prometheus1.yaml b/spec/fixtures/files/prometheus1.yaml index 5c9b78ffe..c796d2171 100644 --- a/spec/fixtures/files/prometheus1.yaml +++ b/spec/fixtures/files/prometheus1.yaml @@ -4,7 +4,8 @@ global: evaluation_interval: 15s external_labels: monitor: master -rule_files: [] +rule_files: +- "$prometheus::{config_dir}/$prometheus::{alertfile_name}.rules" scrape_configs: - job_name: prometheus scrape_interval: 10s diff --git a/spec/fixtures/files/prometheus2.yaml b/spec/fixtures/files/prometheus2.yaml index bfdea9bcc..247511bb0 100644 --- a/spec/fixtures/files/prometheus2.yaml +++ b/spec/fixtures/files/prometheus2.yaml @@ -4,7 +4,8 @@ global: evaluation_interval: 15s external_labels: monitor: master -rule_files: [] +rule_files: +- "$prometheus::{config_dir}/$prometheus::{alertfile_name}.rules" scrape_configs: - job_name: prometheus scrape_interval: 10s From 5be2a1ed932ce5dea50e1021816c4310b2e91c14 Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 30 Jul 2018 10:16:16 +1000 Subject: [PATCH 3/6] Add param 'rule_files' to spec tests and include expected output in yaml fixtures --- spec/classes/prometheus_spec.rb | 2 +- spec/fixtures/files/prometheus1.yaml | 2 +- spec/fixtures/files/prometheus2.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/classes/prometheus_spec.rb b/spec/classes/prometheus_spec.rb index 87e3642e3..845f7b90c 100644 --- a/spec/classes/prometheus_spec.rb +++ b/spec/classes/prometheus_spec.rb @@ -7,7 +7,7 @@ facts.merge(os_specific_facts(facts)) end - [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url' }].each do |parameters| + [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'], }].each do |parameters| context "with parameters #{parameters}" do let(:params) do parameters diff --git a/spec/fixtures/files/prometheus1.yaml b/spec/fixtures/files/prometheus1.yaml index c796d2171..727e6ed74 100644 --- a/spec/fixtures/files/prometheus1.yaml +++ b/spec/fixtures/files/prometheus1.yaml @@ -5,7 +5,7 @@ global: external_labels: monitor: master rule_files: -- "$prometheus::{config_dir}/$prometheus::{alertfile_name}.rules" +- "/etc/prometheus/rules.d/*.rules" scrape_configs: - job_name: prometheus scrape_interval: 10s diff --git a/spec/fixtures/files/prometheus2.yaml b/spec/fixtures/files/prometheus2.yaml index 247511bb0..14b62b803 100644 --- a/spec/fixtures/files/prometheus2.yaml +++ b/spec/fixtures/files/prometheus2.yaml @@ -5,7 +5,7 @@ global: external_labels: monitor: master rule_files: -- "$prometheus::{config_dir}/$prometheus::{alertfile_name}.rules" +- "/etc/prometheus/rules.d/*.rules" scrape_configs: - job_name: prometheus scrape_interval: 10s From a2d6ed3d73668a4362a91d822a33101a10816faf Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 30 Jul 2018 10:27:13 +1000 Subject: [PATCH 4/6] Lint trailing comma in spec tests (thanks Rubocop) --- spec/classes/prometheus_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/prometheus_spec.rb b/spec/classes/prometheus_spec.rb index 845f7b90c..6ea736291 100644 --- a/spec/classes/prometheus_spec.rb +++ b/spec/classes/prometheus_spec.rb @@ -7,7 +7,7 @@ facts.merge(os_specific_facts(facts)) end - [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'], }].each do |parameters| + [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules']}].each do |parameters| context "with parameters #{parameters}" do let(:params) do parameters From 9fd54eb2db550661364691eb8371ba344eec4289 Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 30 Jul 2018 10:28:39 +1000 Subject: [PATCH 5/6] Lint - space inside } missing (Rubocop) --- spec/classes/prometheus_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/prometheus_spec.rb b/spec/classes/prometheus_spec.rb index 6ea736291..e595e2192 100644 --- a/spec/classes/prometheus_spec.rb +++ b/spec/classes/prometheus_spec.rb @@ -7,7 +7,7 @@ facts.merge(os_specific_facts(facts)) end - [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules']}].each do |parameters| + [{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'] }].each do |parameters| context "with parameters #{parameters}" do let(:params) do parameters From 24382eb442899f630ae1b132bb0ca426334a3292 Mon Sep 17 00:00:00 2001 From: Andrew Bramble Date: Mon, 30 Jul 2018 11:25:50 +1000 Subject: [PATCH 6/6] remove redundant prometheus::alertfile_name and bogus reference to same in prometheus::rule_files --- data/defaults.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/data/defaults.yaml b/data/defaults.yaml index c0d081e6b..8abd2e7eb 100644 --- a/data/defaults.yaml +++ b/data/defaults.yaml @@ -200,9 +200,7 @@ prometheus::beanstalkd_exporter::mapping_config: '/etc/beanstalkd-exporter-mappi prometheus::beanstalkd_exporter::config: '/etc/beanstalkd-exporter.conf' prometheus::package_ensure: 'latest' prometheus::package_name: 'prometheus' -prometheus::alertfile_name: 'alert' -prometheus::rule_files: - - "$prometheus::{config_dir}/$prometheus::{alertfile_name}.rules" +prometheus::rule_files: [] prometheus::scrape_configs: - 'job_name': 'prometheus' 'scrape_interval': '10s'