Skip to content

Commit

Permalink
Merge pull request #51 from rbestbmj/elasticsearch_exporter
Browse files Browse the repository at this point in the history
Add elasticsearch exporter
  • Loading branch information
bastelfreak authored Oct 4, 2017
2 parents ce6150d + 94e9322 commit e9d3487
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
136 changes: 136 additions & 0 deletions manifests/elasticsearch_exporter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Class: prometheus::elasticsearch_exporter
#
# This module manages prometheus node elasticsearch_exporter
#
# Parameters:
# [*arch*]
# Architecture (amd64 or i386)
#
# [*bin_dir*]
# Directory where binaries are located
#
# [*download_extension*]
# Extension for the release binary archive
#
# [*download_url*]
# Complete URL corresponding to the where the release binary archive can be downloaded
#
# [*download_url_base*]
# Base URL for the binary archive
#
# [*extra_groups*]
# Extra groups to add the binary user to
#
# [*extra_options*]
# Extra options added to the startup command
#
# [*group*]
# Group under which the binary is running
#
# [*listen_address*]
# Address to listen on for web interface and telemetry. (default ":9108")
#
# [*init_style*]
# Service startup scripts style (e.g. rc, upstart or systemd)
#
# [*install_method*]
# Installation method: url or package (only url is supported currently)
#
# [*manage_group*]
# Whether to create a group for or rely on external code for that
#
# [*manage_service*]
# Should puppet manage the service? (default true)
#
# [*manage_user*]
# Whether to create user or rely on external code for that
#
# [*os*]
# Operating system (linux is the only one supported)
#
# [*package_ensure*]
# If package, then use this for package ensure default 'latest'
#
# [*package_name*]
# The binary package name - not available yet
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*restart_on_change*]
# Should puppet restart the service on configuration change? (default true)
#
# [*service_enable*]
# Whether to enable the service from puppet (default true)
#
# [*service_ensure*]
# State ensured for the service (default 'running')
#
# [*uri*]
# HTTP API address of an Elasticsearch node. (default "http://localhost:9200")
#
# [*user*]
# User which runs the service
#
# [*version*]
# The binary release version
class prometheus::elasticsearch_exporter (
$arch = $::prometheus::params::arch,
$bin_dir = $::prometheus::params::bin_dir,
$download_extension = $::prometheus::params::elasticsearch_exporter_download_extension,
$download_url = undef,
$download_url_base = $::prometheus::params::elasticsearch_exporter_download_url_base,
$extra_groups = $::prometheus::params::elasticsearch_exporter_extra_groups,
$extra_options = '',
$group = $::prometheus::params::elasticsearch_exporter_group,
$init_style = $::prometheus::params::init_style,
$install_method = $::prometheus::params::install_method,
$listen_address = $::prometheus::params::elasticsearch_exporter_listen_address,
Boolean $manage_group = true,
Boolean $manage_service = true,
Boolean $manage_user = true,
$os = $::prometheus::params::os,
$package_ensure = $::prometheus::params::elasticsearch_exporter_package_ensure,
$package_name = $::prometheus::params::elasticsearch_exporter_package_name,
Boolean $purge_config_dir = true,
Boolean $restart_on_change = true,
Boolean $service_enable = true,
$service_ensure = 'running',
$service_name = 'elasticsearch_exporter',
$uri = $::prometheus::params::elasticsearch_exporter_uri,
$user = $::prometheus::params::elasticsearch_exporter_user,
$version = $::prometheus::params::elasticsearch_exporter_version,
) inherits prometheus::params {
$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

$notify_service = $restart_on_change ? {
true => Service[$service_name],
default => undef,
}

$options = "-es.uri ${uri} -web.listen-address ${listen_address} ${extra_options}"

prometheus::daemon { 'elasticsearch_exporter':
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
arch => $arch,
real_download_url => $real_download_url,
bin_dir => $bin_dir,
notify_service => $notify_service,
package_name => $package_name,
package_ensure => $package_ensure,
manage_user => $manage_user,
user => $user,
extra_groups => $extra_groups,
group => $group,
manage_group => $manage_group,
purge => $purge_config_dir,
options => $options,
init_style => $init_style,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
}
}
10 changes: 10 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
$config_template = 'prometheus/prometheus.yaml.erb'
$download_extension = 'tar.gz'
$download_url_base = 'https://github.com/prometheus/prometheus/releases'
$elasticsearch_exporter_download_extension = 'tar.gz'
$elasticsearch_exporter_download_url_base = 'https://github.com/justwatchcom/elasticsearch_exporter/releases'
$elasticsearch_exporter_extra_groups = []
$elasticsearch_exporter_group = 'elasticsearch-exporter'
$elasticsearch_exporter_listen_address = ':9108'
$elasticsearch_exporter_package_ensure = 'latest'
$elasticsearch_exporter_package_name = 'elasticsearch_exporter'
$elasticsearch_exporter_uri = 'http://localhost:9200'
$elasticsearch_exporter_user = 'elasticsearch-exporter'
$elasticsearch_exporter_version = '1.0.1'
$extra_groups = []
$global_config = { 'scrape_interval'=> '15s', 'evaluation_interval'=> '15s', 'external_labels'=> { 'monitor'=>'master'}}
$group = 'prometheus'
Expand Down

0 comments on commit e9d3487

Please sign in to comment.