Puppet Class: prometheus::consul_exporter

Inherits:
prometheus
Defined in:
manifests/consul_exporter.pp

Summary

This module manages prometheus node consul_exporter

Overview

Parameters:

  • arch (String[1]) (defaults to: $prometheus::real_arch)

    Architecture (amd64 or i386)

  • bin_dir (Stdlib::Absolutepath) (defaults to: $prometheus::bin_dir)

    Directory where binaries are located

  • consul_server (String[1])

    HTTP API address of a Consul server or agent. (prefix with https:// to connect over HTTPS) (default “localhost:8500”)

  • consul_health_summary (Boolean)

    Generate a health summary for each service instance. Needs n+1 queries to collect all information. (default true)

  • download_extension (String)

    Extension for the release binary archive

  • download_url (Optional[Prometheus::Uri]) (defaults to: undef)

    Complete URL corresponding to the where the release binary archive can be downloaded

  • download_url_base (Prometheus::Uri)

    Base URL for the binary archive

  • extra_groups (Array)

    Extra groups to add the binary user to

  • extra_options (Optional[String[1]]) (defaults to: undef)

    Extra options added to the startup command

  • group (String[1])

    Group under which the binary is running

  • init_style (Prometheus::Initstyle) (defaults to: $prometheus::init_style)

    Service startup scripts style (e.g. rc, upstart or systemd)

  • install_method (Prometheus::Install) (defaults to: $prometheus::install_method)

    Installation method: url or package (only url is supported currently)

  • log_level (String[1])

    Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] (default “info”)

  • manage_group (Boolean) (defaults to: true)

    Whether to create a group for or rely on external code for that

  • manage_service (Boolean) (defaults to: true)

    Should puppet manage the service? (default true)

  • manage_user (Boolean) (defaults to: true)

    Whether to create user or rely on external code for that

  • os (String[1]) (defaults to: downcase($facts['kernel']))

    Operating system (linux is the only one supported)

  • package_ensure (String[1])

    If package, then use this for package ensure default ‘latest’

  • package_name (String[1])

    The binary package name - not available yet

  • purge_config_dir (Boolean) (defaults to: true)

    Purge config files no longer generated by Puppet

  • restart_on_change (Boolean) (defaults to: true)

    Should puppet restart the service on configuration change? (default true)

  • service_enable (Boolean) (defaults to: true)

    Whether to enable the service from puppet (default true)

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')

    State ensured for the service (default ‘running’)

  • service_name (String[1])

    Name of the consul exporter service (default ‘consul_exporter’)

  • user (String[1])

    User which runs the service

  • version (String[1])

    The binary release version

  • web_listen_address (String[1])

    Address to listen on for web interface and telemetry. (default “:9107”)

  • web_telemetry_path (String[1])

    Path under which to expose metrics. (default “/metrics”)

  • proxy_server (Optional[String[1]]) (defaults to: undef)

    Optional proxy server, with port number if needed. ie: example.com:8080

  • proxy_type (Optional[Enum['none', 'http', 'https', 'ftp']]) (defaults to: undef)

    Optional proxy server type (none|http|https|ftp)

  • export_scrape_job (Boolean) (defaults to: false)
  • scrape_host (Optional[Stdlib::Host]) (defaults to: undef)
  • scrape_port (Stdlib::Port) (defaults to: 9107)
  • scrape_job_name (String[1]) (defaults to: 'consul')
  • scrape_job_labels (Optional[Hash]) (defaults to: undef)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'manifests/consul_exporter.pp', line 62

class prometheus::consul_exporter (
  Boolean $consul_health_summary,
  String[1] $consul_server,
  String $download_extension,
  Prometheus::Uri $download_url_base,
  Array $extra_groups,
  String[1] $group,
  String[1] $log_level,
  String[1] $package_ensure,
  String[1] $package_name,
  String[1] $service_name,
  String[1] $user,
  String[1] $version,
  String[1] $web_listen_address,
  String[1] $web_telemetry_path,
  Boolean $purge_config_dir                                  = true,
  Boolean $restart_on_change                                 = true,
  Boolean $service_enable                                    = true,
  Stdlib::Ensure::Service $service_ensure                    = 'running',
  Boolean $manage_group                                      = true,
  Boolean $manage_service                                    = true,
  Boolean $manage_user                                       = true,
  String[1] $os                                              = downcase($facts['kernel']),
  Prometheus::Initstyle $init_style                          = $prometheus::init_style,
  Prometheus::Install $install_method                        = $prometheus::install_method,
  Optional[String[1]] $extra_options                         = undef,
  Optional[Prometheus::Uri] $download_url                    = undef,
  String[1] $arch                                            = $prometheus::real_arch,
  Stdlib::Absolutepath $bin_dir                              = $prometheus::bin_dir,
  Boolean $export_scrape_job                                 = false,
  Optional[Stdlib::Host] $scrape_host                        = undef,
  Stdlib::Port $scrape_port                                  = 9107,
  String[1] $scrape_job_name                                 = 'consul',
  Optional[Hash] $scrape_job_labels                          = undef,
  Optional[String[1]] $proxy_server                          = undef,
  Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
) inherits prometheus {
  # Prometheus added a 'v' on the realease name at 0.3.0
  if versioncmp ($version, '0.3.0') == -1 {
    fail("I only support consul_exporter version '0.3.0' or higher")
  }

  $real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

  if $consul_health_summary {
    if versioncmp ($version, '0.4.0') == -1 {
      $real_consul_health_summary = '-consul.health-summary'
    } else {
      $real_consul_health_summary = '--consul.health-summary'
    }
  } else {
    $real_consul_health_summary = ''
  }

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

  if versioncmp ($version, '0.4.0') == -1 {
    $options = "-consul.server=${consul_server} ${real_consul_health_summary} -web.listen-address=${web_listen_address} -web.telemetry-path=${web_telemetry_path} -log.level=${log_level} ${extra_options}"
  } else {
    $options = "--consul.server=${consul_server} ${real_consul_health_summary} --web.listen-address=${web_listen_address} --web.telemetry-path=${web_telemetry_path} --log.level=${log_level} ${extra_options}"
  }

  prometheus::daemon { 'consul_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,
    export_scrape_job  => $export_scrape_job,
    scrape_host        => $scrape_host,
    scrape_port        => $scrape_port,
    scrape_job_name    => $scrape_job_name,
    scrape_job_labels  => $scrape_job_labels,
    proxy_server       => $proxy_server,
    proxy_type         => $proxy_type,
  }
}