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')


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

define prometheus::redis_exporter (
    $instance = $title,
    $arguments = '',
    $password = '',
    $hostname = $::hostname,
    $port = '9121'
) {
    require_package('prometheus-redis-exporter')

    $service_name = "prometheus-redis-exporter@${instance}"
    $listen_address = "${hostname}:${port}"

    # 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    => present,
        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  => present,
        content => systemd_template('prometheus-redis-exporter@'),
        restart => true,
        require => Package['prometheus-redis-exporter'],
    }
}