Puppet Class: profile::prometheus::services

Defined in:
modules/profile/manifests/prometheus/services.pp

Overview

SPDX-License-Identifier: Apache-2.0 Uses the prometheus module and generates the specific configuration needed for WMF production

Parameters:

  • replica_label (String) (defaults to: lookup('prometheus::replica_label'))
  • enable_thanos_upload (Boolean) (defaults to: lookup('profile::prometheus::enable_thanos_upload', { 'default_value' => false }))
  • thanos_min_time (Optional[String]) (defaults to: lookup('profile::prometheus::thanos::min_time', { 'default_value' => undef }))
  • alertmanagers (Array[Stdlib::Host]) (defaults to: lookup('alertmanagers', {'default_value' => []}))
  • storage_retention (String) (defaults to: lookup('profile::prometheus::services::storage_retention', {'default_value' => '4032h'}))
  • alerting_relabel_configs_extra (Array) (defaults to: lookup('profile::prometheus::services::alerting_relabel_configs_extra'))


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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'modules/profile/manifests/prometheus/services.pp', line 5

class profile::prometheus::services (
    String $replica_label                 = lookup('prometheus::replica_label'),
    Boolean $enable_thanos_upload         = lookup('profile::prometheus::enable_thanos_upload', { 'default_value' => false }),
    Optional[String] $thanos_min_time     = lookup('profile::prometheus::thanos::min_time', { 'default_value' => undef }),
    Array[Stdlib::Host] $alertmanagers    = lookup('alertmanagers', {'default_value' => []}),
    String $storage_retention             = lookup('profile::prometheus::services::storage_retention', {'default_value' => '4032h'}),
    Array $alerting_relabel_configs_extra = lookup('profile::prometheus::services::alerting_relabel_configs_extra'),
){

    $targets_path = '/srv/prometheus/services/targets'
    $port = 9903

    $config_extra = {
        # All metrics will get an additional 'site' label when queried by
        # external systems (e.g. via federation)
        'external_labels' => {
            'site'       => $::site,
            'replica'    => $replica_label,
            'prometheus' => 'services',
        },
    }

    $jmx_exporter_jobs = [
      {
        'job_name'        => 'cassandra',
        'scrape_timeout'  => '25s',
        'scheme'          => 'http',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/cassandra_*.yaml" ]}
        ],
        # Drop restbase table/cf 'meta' metrics, not needed
        'metric_relabel_configs' => [
          { 'source_labels' => ['columnfamily'],
            'regex'  => 'meta',
            'action' => 'drop',
          },
          { 'source_labels' => ['table'],
            'regex'  => 'meta',
            'action' => 'drop',
          },
        ],
      },
    ]

    prometheus::jmx_exporter_config{ "cassandra_dev_${::site}":
        dest       => "${targets_path}/cassandra_dev_${::site}.yaml",
        class_name => 'role::cassandra_dev',
    }

    prometheus::jmx_exporter_config{ "cassandra_restbase_production_${::site}":
        dest       => "${targets_path}/cassandra_restbase_production_${::site}.yaml",
        class_name => 'role::restbase::production',
    }

    prometheus::jmx_exporter_config{ "cassandra_sessionstore_production_${::site}":
        dest       => "${targets_path}/cassandra_sessionstore_production_${::site}.yaml",
        class_name => 'role::sessionstore',
    }

    prometheus::server { 'services':
        listen_address                 => "127.0.0.1:${port}",
        storage_retention              => $storage_retention,
        scrape_configs_extra           => $jmx_exporter_jobs,
        global_config_extra            => $config_extra,
        alertmanagers                  => $alertmanagers.map |$a| { "${a}:9093" },
        alerting_relabel_configs_extra => $alerting_relabel_configs_extra,
    }

    prometheus::web { 'services':
        proxy_pass => "http://localhost:${port}/services",
    }

    profile::thanos::sidecar { 'services':
        prometheus_port     => $port,
        prometheus_instance => 'services',
        enable_upload       => $enable_thanos_upload,
        min_time            => $thanos_min_time,
    }

    prometheus::rule { 'rules_services.yml':
        instance => 'services',
        source   => 'puppet:///modules/profile/prometheus/rules_services.yml',
    }

    prometheus::pint::source { 'services':
        port => $port,
    }
}