Defined Type: prometheus::targets::mgmt

Defined in:
modules/prometheus/manifests/targets/mgmt.pp

Overview

Parameters:

  • targets (Hash)
  • targets_file (String)
  • extra_labels (Hash[String, String]) (defaults to: {})


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'modules/prometheus/manifests/targets/mgmt.pp', line 6

define prometheus::targets::mgmt (
  Hash $targets,
  String $targets_file,
  Hash[String, String] $extra_labels = {},
) {
  $out = $targets.reduce([]) |$memo, $el| {
    $mgmt_fqdn = $el[0]
    $config = $el[1]

    $fqdn_parts = split($mgmt_fqdn, '[.]')
    $instance = join($fqdn_parts[0, 2], '.')

    $ip4 = {
      # Relabeling will make sure to put everything up to "@"
      # in the "instance" label and use the rest as the target
      # for blackbox exporter to use.
      targets => ["${instance}:22@${mgmt_fqdn}:22"],
      labels  => {
        module      => 'ssh_banner',
        rack        => $config['rack'],
      } + $extra_labels,
    }

    $memo + [$ip4]
  }

  file { $targets_file:
    content => to_yaml(flatten($out)),
  }
}