Skip to content

Commit

Permalink
Merge pull request voxpupuli#30 from steven-aerts/alerting_config
Browse files Browse the repository at this point in the history
Support alerting configuration for prometheus
  • Loading branch information
bastelfreak authored Jun 21, 2017
2 parents a385127 + 0882ca7 commit 73141e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 11 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
# [*scrape_configs*]
# Prometheus scrape configs
#
# [*alert_relabel_config*]
# Prometheus alert relabel config under alerting
#
# [*alertmanagers_config*]
# Prometheus managers config under alerting
#
# Actions:
#
# Requires: see Modulefile
Expand Down Expand Up @@ -136,8 +142,9 @@
$global_config = $::prometheus::params::global_config,
$rule_files = $::prometheus::params::rule_files,
$scrape_configs = $::prometheus::params::scrape_configs,
$alerts = $::prometheus::params::alerts

$alerts = $::prometheus::params::alerts,
$alert_relabel_config = $::prometheus::params::alert_relabel_config,
$alertmanagers_config = $::prometheus::params::alertmanagers_config,
) inherits prometheus::params {
if( versioncmp($::prometheus::version, '1.0.0') == -1 ){
$real_download_url = pick($download_url,
Expand All @@ -155,6 +162,8 @@
validate_hash($global_config)
validate_array($rule_files)
validate_array($scrape_configs)
validate_array($alert_relabel_config)
validate_array($alertmanagers_config)

$config_hash_real = deep_merge($config_defaults, $config_hash)
validate_hash($config_hash_real)
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Class prometheus::params
# Include default parameters for prometheus class
class prometheus::params {
$alert_relabel_config = []
$alertmanagers_config = []
$alertmanager_config_dir = '/etc/alertmanager'
$alertmanager_config_file = "${alertmanager_config_dir}/alertmanager.yaml"
$alertmanager_download_extension = 'tar.gz'
Expand Down
10 changes: 9 additions & 1 deletion templates/prometheus.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
<% global_config = scope.lookupvar('::prometheus::global_config') -%>
<% rule_files = scope.lookupvar('::prometheus::rule_files') -%>
<% scrape_configs = scope.lookupvar('::prometheus::scrape_configs') -%>
<% full_config = { 'global'=>global_config, 'rule_files'=>rule_files, 'scrape_configs'=>scrape_configs } -%>
<% full_config = {
'global'=>global_config,
'rule_files'=>rule_files,
'scrape_configs'=>scrape_configs,
'alerting'=>{
'alert_relabel_configs'=>scope.lookupvar('::prometheus::alert_relabel_config'),
'alertmanagers'=>scope.lookupvar('::prometheus::alertmanagers_config'),
}
} -%>
<%= full_config.to_yaml -%>

0 comments on commit 73141e1

Please sign in to comment.