Skip to content

Commit

Permalink
add pushgateway
Browse files Browse the repository at this point in the history
  • Loading branch information
cristifalcas committed Nov 22, 2016
1 parent 56ed0d0 commit 5c7a36e
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 4 deletions.
4 changes: 2 additions & 2 deletions manifests/alertmanager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# Parameters:
#
# [*package_name*]
# Prometheus package name - not available yet
# alert_manager package name
#
# [*package_ensure*]
# If package, then use this for package ensurel default 'latest'
#
# [*config_dir*]
# Prometheus configuration directory (default /etc/prometheus)
# alert_manager configuration directory (default /etc/prometheus)
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
Expand Down
2 changes: 1 addition & 1 deletion manifests/node_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Parameters:
#
# [*package_name*]
# Prometheus node node_exporter package name - not available yet
# Prometheus node node_exporter package name
#
# [*package_ensure*]
# If package, then use this for package ensure default 'latest'
Expand Down
62 changes: 62 additions & 0 deletions manifests/pushgateway.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Class: prometheus::pushgateway
#
# This module manages prometheus pushgateway
#
# Parameters:
#
# [*package_name*]
# pushgateway package name
#
# [*package_ensure*]
# If package, then use this for package ensurel default 'latest'
#
# [*pushgateway_user*]
# User under which pushgateway will run
# Default prometheus
#
# [*pushgateway_group*]
# Group under which pushgateway will run
# Default prometheus
#
# == CONFIG ==
#
# [*log_format*]
# If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to
# stderr.
#
# [*log_level*]
# Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]. (default info)
#
# [*persistence_file*]
# File to persist metrics. If empty, metrics are only kept in memory.
#
# [*persistence_interval*]
# The minimum interval at which to write out the persistence file. (default 5m0s)
#
# [*web_listen_address*]
# Address to listen on for the web interface and API. (default ":9093")
#
# [*extra_options*]
# Extra options added to alertmanager startup command
#
class prometheus::pushgateway (
$package_name = $::prometheus::pushgateway::params::package_name,
$package_ensure = $::prometheus::pushgateway::params::package_ensure,
$pushgateway_user = $::prometheus::pushgateway::params::pushgateway_user,
$pushgateway_group = $::prometheus::pushgateway::params::pushgateway_group,
$log_format = $::prometheus::pushgateway::params::log_format,
$log_level = $::prometheus::pushgateway::params::log_level,
$persistence_file = $::prometheus::pushgateway::params::persistence_file,
$persistence_interval = $::prometheus::pushgateway::params::persistence_interval,
$web_listen_address = $::prometheus::pushgateway::params::web_listen_address,
$web_telemetry_path = $::prometheus::pushgateway::params::web_telemetry_path,
$extra_options = $::prometheus::pushgateway::params::extra_options,
) inherits prometheus::pushgateway::params {
contain '::prometheus::pushgateway::install'
contain '::prometheus::pushgateway::config'
contain '::prometheus::pushgateway::service'

Class['prometheus::pushgateway::install'] ->
Class['prometheus::pushgateway::config'] ~>
Class['prometheus::pushgateway::service']
}
17 changes: 17 additions & 0 deletions manifests/pushgateway/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Class prometheus::pushgateway::config
#
class prometheus::pushgateway::config {
file { $::prometheus::pushgateway::persistence_file:
ensure => 'file',
mode => '0644',
owner => $::prometheus::pushgateway::pushgateway_user,
group => $::prometheus::pushgateway::pushgateway_group,
}

file { '/etc/sysconfig/pushgateway':
mode => '0644',
owner => 'root',
group => 'root',
content => template("${module_name}/sysconfig/pushgateway"),
}
}
5 changes: 5 additions & 0 deletions manifests/pushgateway/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Class prometheus::pushgateway::install
#
class prometheus::pushgateway::install {
package { $::prometheus::pushgateway::package_name: ensure => $::prometheus::pushgateway::package_ensure, }
}
17 changes: 17 additions & 0 deletions manifests/pushgateway/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Class prometheus::pushgateway::params
#
class prometheus::pushgateway::params {
$package_name = 'pushgateway'
$package_ensure = 'installed'
$pushgateway_user = 'prometheus'
$pushgateway_group = 'prometheus'

$log_format = 'logger:stdout?json=true'
$log_level = undef
$persistence_file = '/etc/prometheus/pushgateway.persistance'
$persistence_interval = undef
$web_listen_address = ':9091'
$web_telemetry_path = undef

$extra_options = undef
}
8 changes: 8 additions & 0 deletions manifests/pushgateway/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# == Class prometheus::pushgateway::service
#
class prometheus::pushgateway::service {
service { 'pushgateway':
ensure => 'running',
enable => true,
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cristifalcas-prometheus",
"version": "1.0.0",
"version": "1.1.0",
"author": "Cristian Falcas",
"summary": "Prometheus Puppet module",
"license": "Apache-2.0",
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/pushgateway_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'prometheus::pushgateway' do
on_supported_os.each do |os, facts|
context "with defaults on #{os}" do
let(:facts) do
facts.merge({:puppetmaster => 'localhost.localdomain'})
end

it { should compile.with_all_deps }
it { should contain_class('prometheus::pushgateway') }
it { should contain_class('prometheus::pushgateway::config') }
it { should contain_class('prometheus::pushgateway::install') }
it { should contain_class('prometheus::pushgateway::service') }
end
end
end
25 changes: 25 additions & 0 deletions templates/sysconfig/pushgateway
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# File managed by puppet
#
ARGS="<% -%>
<% if @log_format -%>
-log.format=<%= scope['prometheus::pushgateway::log_format'] -%>
<% end -%>
<% if @log_level -%>
-log.level=<%= scope['prometheus::pushgateway::log_level'] -%>
<% end -%>
<% if @persistence_file -%>
-persistence.file=<%= scope['prometheus::pushgateway::persistence_file'] -%>
<% end -%>
<% if @persistence_interval -%>
-persistence.interval=<%= scope['prometheus::pushgateway::persistence_interval'] -%>
<% end -%>
<% if @web_listen_address -%>
-web.listen-address=<%= scope['prometheus::pushgateway::web_listen_address'] -%>
<% end -%>
<% if @web_telemetry_path -%>
-web.telemetry-path=<%= scope['prometheus::pushgateway::web_telemetry_path'] -%>
<% end -%>
<% if @extra_options -%>
<%= scope['prometheus::pushgateway::extra_options'] -%>
<% end -%>
"

0 comments on commit 5c7a36e

Please sign in to comment.