Puppet Class: prometheus::node_exporter

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

Overview

Parameters:

  • ignored_devices (String) (defaults to: '^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme[0-9]+n[0-9]+p)[0-9]+$')
  • ignored_fs_types (String) (defaults to: '^(overlay|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|nsfs|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$')
  • ignored_mount_points (String) (defaults to: '^/(sys|proc|dev|var/lib/docker|var/lib/kubelet)($|/)')
  • netstat_fields (String) (defaults to: '^(.*)')
  • vmstat_fields (String) (defaults to: '^(.*)')
  • collectors_extra (Array[String]) (defaults to: [])
  • collector_ntp_server (String) (defaults to: '127.0.0.1')
  • web_listen_address (Pattern[/:\d+$/]) (defaults to: ':9100')


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

class prometheus::node_exporter (
    String $ignored_devices  = '^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme[0-9]+n[0-9]+p)[0-9]+$',
    String $ignored_fs_types  = '^(overlay|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|nsfs|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$',
    String $ignored_mount_points  = '^/(sys|proc|dev|var/lib/docker|var/lib/kubelet)($|/)',
    String $netstat_fields = '^(.*)',
    String $vmstat_fields = '^(.*)',
    Array[String] $collectors_extra = [],
    String $collector_ntp_server = '127.0.0.1',
    Pattern[/:\d+$/] $web_listen_address = ':9100',
) {
    $collectors_default = ['buddyinfo', 'conntrack', 'diskstats', 'entropy', 'edac', 'filefd', 'filesystem', 'hwmon',
        'loadavg', 'mdadm', 'meminfo', 'netdev', 'netstat', 'sockstat', 'stat', 'tcpstat',
        'textfile', 'time', 'uname', 'vmstat']
    $textfile_directory = '/var/lib/prometheus/node.d'

    package { 'prometheus-node-exporter':
      ensure => 'present'
    }

    # Configuration compatibile less than 0.16
    # TODO: remove after Trusty is gone.
    if ($::lsbdistcodename == 'trusty') {
        $collectors_enabled = join(sort(concat($collectors_default, $collectors_extra)), ',')

        file { '/etc/default/prometheus-node-exporter':
            ensure  => present,
            mode    => '0444',
            owner   => 'root',
            group   => 'root',
            content => template('prometheus/etc/default/prometheus-node-exporter.erb'),
            notify  => Service['prometheus-node-exporter'],
        }
    }
    # New configuration style (0.16+)
    else {
        $collectors_enabled = concat($collectors_default, $collectors_extra)

        file { '/etc/default/prometheus-node-exporter':
              ensure  => present,
              mode    => '0444',
              owner   => 'root',
              group   => 'root',
              content => template('prometheus/etc/default/prometheus-node-exporter-0.17.erb'),
              notify  => Service['prometheus-node-exporter'],
        }

        # Disabled because broken (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=922803)
        service { 'prometheus-node-exporter-ipmitool-sensor.timer':
            ensure   => 'stopped',
            provider => 'systemd',
            enable   => 'mask',
            require  => Package['prometheus-node-exporter'],
        }

        # Disabled in favor of internal smart module (smart-data-dump.py)
        service { 'prometheus-node-exporter-smartmon.timer':
            ensure   => 'stopped',
            provider => 'systemd',
            enable   => 'mask',
            require  => Package['prometheus-node-exporter'],
        }
    }

    # members of this group are able to publish metrics
    # via the 'textfile' collector by writing files to $textfile_directory.
    # prometheus-node-exporter will export all files matching *.prom
    group { 'prometheus-node-exporter':
        ensure => present,
    }

    file { $textfile_directory:
        ensure  => directory,
        mode    => '0770',
        owner   => 'prometheus',
        group   => 'prometheus-node-exporter',
        require => [Package['prometheus-node-exporter'],
                    Group['prometheus-node-exporter']],
    }

    base::service_unit { 'prometheus-node-exporter':
        ensure           => present,
        refresh          => true,
        systemd_override => init_template('prometheus-node-exporter', 'systemd_override'),
        upstart          => upstart_template('prometheus-node-exporter'),
        require          => Package['prometheus-node-exporter'],
    }

    if os_version('debian >= jessie') {
        base::service_auto_restart { 'prometheus-node-exporter': }
    }
}