Defined Type: prometheus::node_textfile

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

Overview

SPDX-License-Identifier: Apache-2.0

Define: prometheus::node_textfile

This define sets up a local script which runs periodically with the intention to export local metrics under /var/lib/prometheus/node.d/foo where foo is the name/title of the define

filesource

A Puppet file source for the exporter script

interval

An interval for how often the script should run, specified in systemd timer syntax, see the systemd.time manpage

*run_cmd'

How the exporter script should be started

extra_packages

If the script requires additional Debian packages to be installed they can be configured here.

user

Configures the user to run the script under, defaults to “root”

Parameters:

  • filesource (Stdlib::Filesource)
  • interval (String)
  • run_cmd (String)
  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • user (Optional[String]) (defaults to: 'root')
  • extra_packages (Optional[Array[String]]) (defaults to: [])


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

define prometheus::node_textfile (
    Stdlib::Filesource         $filesource,
    String                     $interval,
    String                     $run_cmd,
    Wmflib::Ensure             $ensure          = 'present',
    Optional[String]           $user            = 'root',
    Optional[Array[String]]    $extra_packages  = [],
) {
    if $extra_packages {
        ensure_packages($extra_packages, {'ensure' => $ensure})
    }

    file { "/usr/local/bin/${title}":
        ensure => $ensure,
        mode   => '0555',
        source => $filesource
    }

    systemd::timer::job { "prometheus-node-textfile-${title}":
        ensure      => $ensure,
        description => "Systemd timer to gather node metrics for ${title}",
        user        => $user,
        command     => $run_cmd,
        interval    => {'start' => 'OnCalendar', 'interval' => $interval},
    }
}