Defined Type: prometheus::node_file_count

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

Overview

Parameters:

  • paths (Array[String])
  • outfile (Stdlib::AbsolutePath)
  • metric (String) (defaults to: 'node_files_total')
  • ensure (Wmflib::Ensure) (defaults to: 'present')


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

define prometheus::node_file_count (
    Array[String] $paths,
    Stdlib::AbsolutePath $outfile,
    String $metric = 'node_files_total',
    Wmflib::Ensure $ensure = 'present',
) {

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

    if !($metric =~ /^node_[a-z_]*_total$/) {
        fail("\$metric should begin with 'node_' then lowercase chars or _ and end with '_total' but is [${metric}]")
    }

    require_package(['python3-prometheus-client'])

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

    # Collect every minute
    cron { $title:
        ensure  => $ensure,
        user    => 'root',
        command => inline_template("/usr/local/bin/prometheus-file-count --outfile <%= @outfile %> --metric <%= @metric %> <%= @paths.map{ | i | '\"' + i + '\"' }.join(' ') %>"),
        require => Class['prometheus::node_exporter'],
    }
}