Defined Type: prometheus::redis_exporter

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

Overview

Parameters:

  • instance (Any) (defaults to: $title)
  • arguments (Any) (defaults to: '')
  • password (Any) (defaults to: '')
  • hostname (Any) (defaults to: $::hostname)
  • port (Any) (defaults to: '9121')
  • ensure (Wmflib::Ensure) (defaults to: 'present')


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
# File 'modules/prometheus/manifests/redis_exporter.pp', line 21

define prometheus::redis_exporter (
    $instance = $title,
    $arguments = '',
    $password = '',
    $hostname = $::hostname,
    $port = '9121',
    Wmflib::Ensure $ensure = 'present',
) {
    $service_name = "prometheus-redis-exporter@${instance}"
    $listen_address = "${hostname}:${port}"

    if $ensure == 'present' {
        ensure_packages('prometheus-redis-exporter')

        Package['prometheus-redis-exporter'] -> Systemd::Service[$service_name]

        # We're going with multiple prometheus-redis-exporter, mask and stop the default single-instance one.
        exec { "mask_default_redis_exporter_${instance}":
            command => '/bin/systemctl mask prometheus-redis-exporter.service ; /bin/systemctl stop prometheus-redis-exporter.service',
            creates => '/etc/systemd/system/prometheus-redis-exporter.service',
        }
    }

    file { "/etc/default/${service_name}":
        ensure    => stdlib::ensure($ensure, 'file'),
        mode      => '0400',
        owner     => 'root',
        group     => 'root',
        content   => "ARGS=\"-redis.addr localhost:${instance} ${arguments}\"\nREDIS_PASSWORD=\"${password}\"",
        show_diff => false,
        notify    => Systemd::Service[$service_name],
    }

    systemd::service { $service_name:
        ensure  => $ensure,
        content => systemd_template('prometheus-redis-exporter@'),
        restart => true,
    }

    profile::auto_restarts::service { $service_name:
        ensure => $ensure,
    }
}