Puppet Class: puppet_metrics_collector

Defined in:
manifests/init.pp

Summary

This module manages the collection of Puppet and system Metrics

Overview

Optional Enum: The metrics server type to send data to. Default: undef

@ param metrics_server_hostname Optional String: The hostname of the metrics server to send data to. Default: undef

@ param metrics_server_port Optional Integer: The port number of the metrics server to send data to. Default: undef

Optional String: (Deprecated)The database name on the metrics server to send data to. Default: undef

Optional String: Allows you to define the command that is executed to gather metrics. Default: undef

Optional String: Collection of ActiveMQ metrics has been removed, but the parameters are left to avoid breaking upgrades Optional String: Collection of ActiveMQ metrics has been removed, but the parameters are left to avoid breaking upgrades Optional Integer: Collection of ActiveMQ metrics has been removed, but the parameters are left to avoid breaking upgrades

Parameters:

  • puppetserver_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of Puppetserver metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • output_dir (String) (defaults to: '/opt/puppetlabs/puppet-metrics-collector')

    The directory to write the metrics to. Default: ‘/opt/puppetlabs/puppet-metrics-collector’

  • collection_frequency (Integer) (defaults to: 5)

    The frequency to collect metrics in minutes. Default: ‘5’

  • retention_days (Integer) (defaults to: 90)

    The number of days to retain metrics. Default: ‘90’

  • puppetserver_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('master'))

    The list of puppetserver hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the puppetserver profile.

  • puppetserver_port (Integer) (defaults to: 8140)

    Port to connect to puppetserver on. Default: ‘8140’

  • puppetdb_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of PuppetDB metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • puppetdb_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('puppetdb'))

    The list of puppetdb hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the puppetdb profile.

  • puppetdb_port (Integer) (defaults to: 8081)

    Port to connect to puppetdb on. Default: ‘8081’

  • orchestrator_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of Orchestrator metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • orchestrator_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('orchestrator'))

    The list of orchestrator hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the orchestrator profile.

  • orchestrator_port (Integer) (defaults to: 8143)

    Port to connect to orchestrator on. Default: ‘8143’

  • console_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of PE Console metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • console_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('console'))

    The list of console hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the console profile.

  • console_port (Integer) (defaults to: 4433)

    Port to connect to console on. Default: ‘4433’

  • ace_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of Ace metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • ace_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('ace_server'))

    The list of ace hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the ace profile.

  • ace_port (Integer) (defaults to: 44633)

    Port to connect to ace on. Default: ‘44633’

  • bolt_metrics_ensure (String) (defaults to: 'present')

    Whether to enable or disable the collection of Bolt metrics. Valid values are ‘present’, and ‘absent’. Default : ‘present’

  • bolt_hosts (Array[String]) (defaults to: puppet_metrics_collector::hosts_with_pe_profile('bolt_server'))

    The list of bolt hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the bolt profile.

  • bolt_port (Integer) (defaults to: 62658)

    Port to connect to bolt on. Default: ‘62658’

  • metrics_server_type (Optional[Enum['influxdb', 'graphite', 'splunk_hec']]) (defaults to: undef)
  • metrics_server_db_name (Optional[String]) (defaults to: undef)
  • override_metrics_command (Optional[String]) (defaults to: undef)
  • activemq_metrics_ensure (String) (defaults to: 'absent')
  • activemq_hosts (Array[String]) (defaults to: [])
  • activemq_port (Integer) (defaults to: 8161)
  • puppetserver_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the puppetserver metrics collection.

  • puppetdb_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the puppetdb metrics collection.

  • orchestrator_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the orchestrator_excludes metrics collection.

  • console_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the console_excludes metrics collection.

  • ace_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the ace_excludes metrics collection.

  • bolt_excludes (Optional[Array[String]]) (defaults to: undef)

    An Array of metrics to exclude from the bolt_excludes metrics collection.

  • activemq_excludes (Optional[Array[String]]) (defaults to: undef)

    Collection of ActiveMQ metrics has been removed, but the parameters are left to avoid breaking upgrades

  • metrics_server_hostname (Optional[String]) (defaults to: undef)

    The hostname of the metrics server to send data to. Default: undef

  • metrics_server_port (Optional[Integer]) (defaults to: undef)

    (Deprecated) The port number of the metrics server to send data to. Default: undef



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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'manifests/init.pp', line 108

class puppet_metrics_collector (
  String                  $puppetserver_metrics_ensure = 'present',
  String                  $output_dir                  = '/opt/puppetlabs/puppet-metrics-collector',
  Integer                 $collection_frequency        = 5,
  Integer                 $retention_days              = 90,
  Array[String]           $puppetserver_hosts          = puppet_metrics_collector::hosts_with_pe_profile('master'),
  Integer                 $puppetserver_port           = 8140,
  String                  $puppetdb_metrics_ensure     = 'present',
  Array[String]           $puppetdb_hosts              = puppet_metrics_collector::hosts_with_pe_profile('puppetdb'),
  Integer                 $puppetdb_port               = 8081,
  String                  $orchestrator_metrics_ensure = 'present',
  Array[String]           $orchestrator_hosts          = puppet_metrics_collector::hosts_with_pe_profile('orchestrator'),
  Integer                 $orchestrator_port           = 8143,
  String                  $console_metrics_ensure      = 'present',
  Array[String]           $console_hosts               = puppet_metrics_collector::hosts_with_pe_profile('console'),
  Integer                 $console_port                = 4433,
  String                  $ace_metrics_ensure          = 'present',
  Array[String]           $ace_hosts                   = puppet_metrics_collector::hosts_with_pe_profile('ace_server'),
  Integer                 $ace_port                    = 44633,
  String                  $bolt_metrics_ensure         = 'present',
  Array[String]           $bolt_hosts                  = puppet_metrics_collector::hosts_with_pe_profile('bolt_server'),
  Integer                 $bolt_port                   = 62658,
  # Collection of ActiveMQ metrics has been removed, but the parameters are left to avoid breaking upgrades
  String                  $activemq_metrics_ensure     = 'absent',
  Array[String]           $activemq_hosts              = [],
  Integer                 $activemq_port               = 8161,
  Optional[String]        $override_metrics_command    = undef,
  Optional[Array[String]] $puppetserver_excludes       = undef,
  Optional[Array[String]] $puppetdb_excludes           = undef,
  Optional[Array[String]] $orchestrator_excludes       = undef,
  Optional[Array[String]] $console_excludes            = undef,
  Optional[Array[String]] $ace_excludes                = undef,
  Optional[Array[String]] $bolt_excludes               = undef,
  Optional[Array[String]] $activemq_excludes           = undef,
  Optional[Enum['influxdb', 'graphite', 'splunk_hec']] $metrics_server_type = undef,
  Optional[String]        $metrics_server_hostname     = undef,
  Optional[Integer]       $metrics_server_port         = undef,
  Optional[String]        $metrics_server_db_name      = undef,
) {
  puppet_metrics_collector::deprecated_parameter { 'puppet_metrics_collector::metrics_server_type': }
  puppet_metrics_collector::deprecated_parameter { 'puppet_metrics_collector::metrics_server_hostname': }
  puppet_metrics_collector::deprecated_parameter { 'puppet_metrics_collector::metrics_server_port': }
  puppet_metrics_collector::deprecated_parameter { 'puppet_metrics_collector::metrics_server_db_name': }

  $config_dir  = "${output_dir}/config"
  $scripts_dir = "${output_dir}/scripts"

  if $facts.dig('puppet_metrics_collector', 'have_systemd') {
    # If the puppet_metrics_collector::system class is evaluted first,
    # File[$output_dir] will already be defined along with common scripts.
    if !defined(File[$output_dir]) {
      file { [$output_dir, $scripts_dir]:
        ensure => directory,
      }

      file { "${scripts_dir}/create-metrics-archive":
        ensure => file,
        mode   => '0755',
        source => 'puppet:///modules/puppet_metrics_collector/create-metrics-archive',
      }

      file { "${scripts_dir}/metrics_tidy":
        ensure => file,
        mode   => '0744',
        source => 'puppet:///modules/puppet_metrics_collector/metrics_tidy',
      }
    }

    file { $config_dir:
      ensure => directory,
    }

    file { "${scripts_dir}/pe_metrics.rb" :
      ensure => file,
      mode   => '0755',
      source => 'puppet:///modules/puppet_metrics_collector/pe_metrics.rb',
    }

    file { "${scripts_dir}/tk_metrics" :
      ensure => file,
      mode   => '0755',
      source => 'puppet:///modules/puppet_metrics_collector/tk_metrics',
    }

    exec { 'puppet_metrics_collector_daemon_reload':
      command     => 'systemctl daemon-reload',
      path        => ['/bin', '/usr/bin'],
      refreshonly => true,
    }

    include puppet_metrics_collector::service::puppetserver
    include puppet_metrics_collector::service::puppetdb
    include puppet_metrics_collector::service::orchestrator
    include puppet_metrics_collector::service::console
    include puppet_metrics_collector::service::ace
    include puppet_metrics_collector::service::bolt

    # LEGACY CLEANUP

    # Clean up old metrics directories created by the module before it was renamed.

    $legacy_dir      = '/opt/puppetlabs/pe_metric_curl_cron_jobs'
    $safe_output_dir = shellquote($output_dir)

    exec { "migrate ${legacy_dir} directory":
      path    => '/bin:/usr/bin',
      command => "mv ${legacy_dir} ${safe_output_dir}",
      onlyif  => "[ ! -e ${safe_output_dir} -a -e ${legacy_dir} ]",
      before  => File[$output_dir],
    }

    $legacy_files = [
      '/opt/puppetlabs/bin/puppet-metrics-collector',
      '/opt/puppetlabs/puppet-metrics-collector/bin',
      "${scripts_dir}/puma_metrics",
      "${scripts_dir}/json2timeseriesdb",
    ]

    file { $legacy_files :
      ensure => absent,
      force  => true,
    }

    # Manual cleanup of deprecated AMQ jobs
    cron { ['activemq_metrics_collection', 'activemq_metrics_tidy']:
      ensure => absent,
    }
  } else {
    notify { 'systemd_provider_warning':
      message  => 'This module only works with systemd as the provider',
      loglevel => warning,
    }
  }
}