Defined Type: prometheus::node_file_age

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

Overview

Parameters:

  • paths (Array[Stdlib::Unixpath, 1])
  • outfile (Stdlib::Unixpath)
  • metric (String) (defaults to: 'node_file_age_timestamp_seconds')
  • 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
# File 'modules/prometheus/manifests/node_file_age.pp', line 21

define prometheus::node_file_age (
    Array[Stdlib::Unixpath, 1] $paths,
    Stdlib::Unixpath $outfile,
    String $metric = 'node_file_age_timestamp_seconds',
    Wmflib::Ensure $ensure = 'present',
) {

    if !($outfile =~ /\.prom$/) {
        fail("\$outfile should end with '.prom' but is [${outfile}]")
    }

    stdlib::ensure_packages(['python3-prometheus-client'])

    if (!defined(File['/usr/local/bin/prometheus-file-age'])) {
        file { '/usr/local/bin/prometheus-file-age':
            ensure => $ensure,
            mode   => '0555',
            owner  => 'root',
            group  => 'root',
            source => 'puppet:///modules/prometheus/usr/local/bin/prometheus-file-age.py',
        }
    }

    # Collect every minute
    $safe_title = regsubst($title, ' ', '_', 'G')
    systemd::timer::job { $safe_title:
        ensure      => $ensure,
        description => 'Regular job to collect file age metrics',
        user        => 'root',
        command     => inline_template("/usr/local/bin/prometheus-file-age --outfile <%= @outfile %> --metric <%= @metric %> <%= @paths.map{ | i | '\"' + i + '\"' }.join(' ') %>"),
        interval    => {'start' => 'OnCalendar', 'interval' => 'minutely'},
        require     => Class['prometheus::node_exporter'],
    }
}