Puppet Class: prometheus::statsd_exporter

Defined in:
modules/prometheus/manifests/statsd_exporter.pp

Overview

Parameters:

  • mappings (Array[Hash]) (defaults to: [])
  • relay_address (String) (defaults to: '')
  • listen_address (String) (defaults to: ':9112')
  • arguments (String) (defaults to: '')


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'modules/prometheus/manifests/statsd_exporter.pp', line 20

class prometheus::statsd_exporter (
    Array[Hash] $mappings = [],
    String $relay_address = '',
    String $listen_address = ':9112',
    String $arguments = '',
) {
    require_package('prometheus-statsd-exporter')

    $basedir = '/etc/prometheus'
    $config = "${basedir}/statsd_exporter.conf"
    $defaults = {
      'timer_type' => 'summary',
      'quantiles'  => [
        { 'quantile' => '0.99',
          'error'    => '0.001' },
        { 'quantile' => '0.95',
          'error'    => '0.001' },
        { 'quantile' => '0.75',
          'error'    => '0.001' },
        { 'quantile' => '0.50',
          'error'    => '0.005' },
      ],
    }

    file { $basedir:
        ensure => directory,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
    }

    file { $config:
        content => ordered_yaml({'defaults' => $defaults, 'mappings' => $mappings}),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
    }

    file { '/etc/default/prometheus-statsd-exporter':
        ensure  => present,
        mode    => '0444',
        owner   => 'root',
        group   => 'root',
        content => inline_template(join(['ARGS="',
            '--statsd.mapping-config=<%= @config %>',
            '<% if not @relay_address.empty? %>--statsd.relay-address=<%= @relay_address %><% end %>',
            '--web.listen-address=<%= @listen_address %>',
            '<%= @arguments %>',
        '"'], ' ')),
        notify  => Service['prometheus-statsd-exporter'],
    }

    service { 'prometheus-statsd-exporter':
        ensure  => running,
    }

    base::service_auto_restart { 'prometheus-statsd-exporter': }
}