2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '1.6.0'
modulesync_config_version: '1.8.0'
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,38 @@ matrix:
include:
- rvm: 2.1.9
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=16
- rvm: 2.4.2
env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12
- rvm: 2.4.3
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
- rvm: 2.4.2
- rvm: 2.5.0
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
- rvm: 2.4.3
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=rubocop
- rvm: 2.4.2
- rvm: 2.4.3
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes
- rvm: 2.4.2
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.2
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.2
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.2
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v4.1.0](https://github.com/voxpupuli/puppet-prometheus/tree/v4.1.0) (2018-02-14)

[Full Changelog](https://github.com/voxpupuli/puppet-prometheus/compare/v4.0.0...v4.1.0)

**Implemented enhancements:**

- Add support for rabbitmq\_exporter [\#149](https://github.com/voxpupuli/puppet-prometheus/issues/149)
- Added redis\_exporter module [\#157](https://github.com/voxpupuli/puppet-prometheus/pull/157) ([yackushevas](https://github.com/yackushevas))
- Add rabbitmq exporter [\#153](https://github.com/voxpupuli/puppet-prometheus/pull/153) ([costela](https://github.com/costela))
- add envvars support to daemon [\#151](https://github.com/voxpupuli/puppet-prometheus/pull/151) ([costela](https://github.com/costela))
- adding remote\_write support [\#144](https://github.com/voxpupuli/puppet-prometheus/pull/144) ([kalinux](https://github.com/kalinux))

**Fixed bugs:**

- Alert rule validation error [\#143](https://github.com/voxpupuli/puppet-prometheus/issues/143)
- Facter error on older distributions \(Ubuntu Trusty\) [\#142](https://github.com/voxpupuli/puppet-prometheus/issues/142)
- bug: alert rules are still 1.0 syntax for Prometheus 2 [\#120](https://github.com/voxpupuli/puppet-prometheus/issues/120)
- \[minor\] change default alerts to empty hash [\#152](https://github.com/voxpupuli/puppet-prometheus/pull/152) ([costela](https://github.com/costela))

**Closed issues:**

- Add ability to set environment variables for daemons [\#150](https://github.com/voxpupuli/puppet-prometheus/issues/150)

**Merged pull requests:**

- update blackbox\_exporter.pp inline documentation [\#155](https://github.com/voxpupuli/puppet-prometheus/pull/155) ([tobald](https://github.com/tobald))
- Ruby 1.8 compatibility \(Agent-side\) [\#146](https://github.com/voxpupuli/puppet-prometheus/pull/146) ([sathieu](https://github.com/sathieu))
- Fail silently when service is not installed [\#145](https://github.com/voxpupuli/puppet-prometheus/pull/145) ([vladgh](https://github.com/vladgh))
- release 4.0.0 [\#140](https://github.com/voxpupuli/puppet-prometheus/pull/140) ([bastelfreak](https://github.com/bastelfreak))
- Add support for snmp\_exporter [\#125](https://github.com/voxpupuli/puppet-prometheus/pull/125) ([sathieu](https://github.com/sathieu))
- new feature - consul\_exporter [\#36](https://github.com/voxpupuli/puppet-prometheus/pull/36) ([pjfbashton](https://github.com/pjfbashton))

## [v4.0.0](https://github.com/voxpupuli/puppet-prometheus/tree/v4.0.0) (2018-01-04)

[Full Changelog](https://github.com/voxpupuli/puppet-prometheus/compare/v3.1.0...v4.0.0)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '~> 2.5.0', :require => false
gem 'puppetlabs_spec_helper', '~> 2.6.0', :require => false
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
Expand Down Expand Up @@ -57,7 +57,7 @@ group :system_tests do
end

group :release do
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator'
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2'
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem'
gem 'puppet-strings', '~> 1.0', :require => false
Expand Down
126 changes: 123 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| >= 0.16.2 | latest |

node_exporter >= 0.15.0
consul_exporter >= 0.3.0


## Background
Expand All @@ -24,7 +25,7 @@ This module automates the install and configuration of Prometheus monitoring too
* Installs a configuration file for prometheus daemon (/etc/prometheus/prometheus.yaml) or for alertmanager (/etc/prometheus/alert.rules)
* Manages the services via upstart, sysv, or systemd
* Optionally creates alert rules
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter, consul_exporter, redis_exporter

## Usage

Expand All @@ -35,7 +36,7 @@ On the server (for prometheus version < 1.0.0):
class { '::prometheus':
global_config => { 'scrape_interval'=> '15s', 'evaluation_interval'=> '15s', 'external_labels'=> { 'monitor'=>'master'}},
rule_files => [ "/etc/prometheus/alert.rules" ],
scrape_configs => [
scrape_configs => [
{ 'job_name'=> 'prometheus',
'scrape_interval'=> '10s',
'scrape_timeout' => '10s',
Expand All @@ -59,6 +60,25 @@ class { 'prometheus':
localstorage => '/prometheus/prometheus',
}
```
On the server (for prometheus version >= 2.0.0):

```puppet
class { '::prometheus':
version => '2.0.0',
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'}
}
]
}
]
}
```

or simply:
```puppet
Expand Down Expand Up @@ -93,6 +113,10 @@ alertrules:

When using prometheus >= 2.0, we use the new yaml format (https://prometheus.io/docs/prometheus/2.0/migration/#recording-rules-and-alerts) configuration

```puppet
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.' } }]}]},
```

```yaml
alerts:
groups:
Expand Down Expand Up @@ -126,11 +150,107 @@ class { 'prometheus::node_exporter':

For more information regarding class parameters please take a look at class docstring.

## Example

Real Prometheus >=2.0.0 setup example including alertmanager and slack_configs.

```puppet
include profiles::prometheus
class { '::prometheus':
version => '2.0.0',
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'}
}
]
},
{ 'job_name' => 'node',
'scrape_interval' => '5s',
'scrape_timeout' => '5s',
'static_configs' => [
{ 'targets' => [ 'nodexporter.domain.com:9100' ],
'labels' => { 'alias'=> 'Node'}
}
]
}
],
alertmanagers_config => [{ 'static_configs' => [{'targets' => [ 'localhost:9093' ]}]}],
}
class { '::prometheus::alertmanager':
version => '0.13.0',
route => { 'group_by' => [ 'alertname', 'cluster', 'service' ], 'group_wait'=> '30s', 'group_interval'=> '5m', 'repeat_interval'=> '3h', 'receiver'=> 'slack' },
receivers => [ { 'name' => 'slack', 'slack_configs'=> [ { 'api_url'=> 'https://hooks.slack.com/services/ABCDEFG123456', 'channel' => '#channel', 'send_resolved' => true, 'username' => 'username'}] }]
}
```

the same in hiera

```puppet
rometheus::version: '2.0.0'
prometheus::scrape_configs:
- job_name: 'nodexporter'
scrape_interval: '10s'
scrape_timeout: '10s'
static_configs:
- targets:
- nodexporter.domain.com:9100
labels:
alias: 'nodexporter'
- job_name: prometheus
scrape_interval: 10s
scrape_timeout: 10s
static_configs:
- targets:
- localhost:9090
labels:
alias: Prometheus
prometheus::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.'
prometheus::alertmanagers_config:
- static_configs:
- targets:
- localhost:9093
prometheus::alertmanager::version: '0.13.0'
prometheus::alertmanager::route:
group_by:
- alertname
- cluster
- service
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: slack
prometheus::alertmanager::receivers:
- name: slack
slack_configs:
- api_url: https://hooks.slack.com/services/ABCDEFG123456
channel: "#channel"
send_resolved: true
username: username
```
Test you commit with vagrant https://github.com/kalinux/vagrant-puppet-prometheus.git

## Limitations/Known issues

In version 0.1.14 of this module the alertmanager was configured to run as the service `alert_manager`. This has been changed in version 0.2.00 to be `alertmanager`.

Do not use version 1.0.0 of Prometheus: https://groups.google.com/forum/#!topic/prometheus-developers/vuSIxxUDff8 ; it does break the compatibility with thus module!

Even if the module has templates for several linux distributions, only RH family distributions were tested.

8 changes: 6 additions & 2 deletions lib/facter/alert_manager_running.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require 'puppet'

service = Puppet::Type.type(:service).new(name: 'alert_manager')
service = Puppet::Type.type(:service).new(:name => 'alert_manager') # rubocop:disable Style/HashSyntax

Facter.add('prometheus_alert_manager_running') do
setcode do
service.provider.status == :running
begin
service.provider.status == :running
rescue Puppet::Error
false
end
end
end
12 changes: 10 additions & 2 deletions manifests/alertmanager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,17 @@
mode => '0755',
}

$options = "-config.file=${prometheus::alertmanager::config_file} -storage.path=${prometheus::alertmanager::storage_path} ${prometheus::alertmanager::extra_options}"
if( versioncmp($::prometheus::alertmanager::version, '0.12.0') == 1 ){
$options = "--config.file=${prometheus::alertmanager::config_file} --storage.path=${prometheus::alertmanager::storage_path} ${prometheus::alertmanager::extra_options}"
} else {
$options = "-config.file=${prometheus::alertmanager::config_file} -storage.path=${prometheus::alertmanager::storage_path} ${prometheus::alertmanager::extra_options}"
}
} else {
$options = "-config.file=${prometheus::alertmanager::config_file} ${prometheus::alertmanager::extra_options}"
if( versioncmp($::prometheus::alertmanager::version, '0.12.0') == 1 ){
$options = "--config.file=${prometheus::alertmanager::config_file} ${prometheus::alertmanager::extra_options}"
} else {
$options = "-config.file=${prometheus::alertmanager::config_file} ${prometheus::alertmanager::extra_options}"
}
}

prometheus::daemon { $service_name:
Expand Down
7 changes: 4 additions & 3 deletions manifests/blackbox_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@
# simple_ssl:
# prober: http
# timeout: 10s
# valid_status_codes: 2xx
# fail_if_not_ssl: true
# http:
# fail_if_not_ssl: true
# easy_tcp:
# prober: tcp
# preferred_ip_protocol: ip4
# tcp:
# preferred_ip_protocol: ip4
class prometheus::blackbox_exporter (
Hash $modules = {},
String $arch = $::prometheus::params::arch,
Expand Down
4 changes: 4 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$rule_files,
$scrape_configs,
$remote_read_configs,
$remote_write_configs,
$config_template = $::prometheus::params::config_template,
$storage_retention = $::prometheus::params::storage_retention,
) {
Expand All @@ -16,6 +17,9 @@
if $remote_read_configs != [] {
fail('remote_read_configs requires prometheus 2.X')
}
if $remote_write_configs != [] {
fail('remote_write_configs requires prometheus 2.X')
}
$daemon_flags = [
"-config.file=${::prometheus::config_dir}/prometheus.yaml",
"-storage.local.path=${::prometheus::localstorage}",
Expand Down
Loading