Puppet Class: prometheus::blackbox::modules::service_catalog

Defined in:
modules/prometheus/manifests/blackbox/modules/service_catalog.pp

Overview

Generate blackbox modules configuration from service::catalog entries. The main use case is to have customised modules for HTTP(s) services.

Parameters:

  • services_config (Hash[String, Wmflib::Service])


5
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
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
# File 'modules/prometheus/manifests/blackbox/modules/service_catalog.pp', line 5

class prometheus::blackbox::modules::service_catalog (
  Hash[String, Wmflib::Service] $services_config,
) {
  $modules = $services_config.reduce({}) |$memo, $el| {
    $service_name = $el[0]
    $service_config = $el[1]

    $module_options = wmflib::service::probe::module_options($service_name, $service_config)

    if 'probes' in $service_config {
      # XXX support more than one probe if/when needed
      $probe = $service_config['probes'][0]
      if $probe['type'] == 'http' {
        $http_options = wmflib::service::probe::http_module_options($service_name, $service_config)

        $service_modules = {
          "http_${service_name}_ip4" => {
            'prober' => 'http',
            'http'   => {
              'preferred_ip_protocol' => 'ip4',
            } + $http_options,
          } + $module_options,
          "http_${service_name}_ip6" => {
            'prober' => 'http',
            'http'   => {
              'preferred_ip_protocol' => 'ip6',
            } + $http_options,
          } + $module_options,
        }
      } elsif $probe['type'] =~ /^tcp/ {
        $tcp_options = wmflib::service::probe::tcp_module_options($service_name, $service_config)
        $service_modules = {
          "tcp_${service_name}_ip4" => {
            'prober' => 'tcp',
            'tcp'   => {
              'preferred_ip_protocol' => 'ip4',
            } + $tcp_options,
          } + $module_options,
          "tcp_${service_name}_ip6" => {
            'prober' => 'tcp',
            'tcp'   => {
              'preferred_ip_protocol' => 'ip6',
            } + $tcp_options,
          } + $module_options,
        }
      }
    } else {
      $service_modules = {}
    }

    $memo + $service_modules
  }

  file { '/etc/prometheus/blackbox.yml.d/service_catalog.yml':
    content => to_yaml({'modules' => $modules}),
    mode    => '0444',
    owner   => 'root',
    group   => 'root',
    notify  => Exec['assemble blackbox.yml'],
  }
}