Puppet Class: profile::prometheus::beta

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

Overview

Parameters:

  • storage_retention (String) (defaults to: lookup('prometheus::server::storage_retention', {'default_value' => '730h'}))
  • alertmanagers (Array[Stdlib::Host]) (defaults to: lookup('alertmanagers', {'default_value' => []}))


1
2
3
4
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'modules/profile/manifests/prometheus/beta.pp', line 1

class profile::prometheus::beta (
    String $storage_retention = lookup('prometheus::server::storage_retention', {'default_value' => '730h'}),
    Array[Stdlib::Host] $alertmanagers = lookup('alertmanagers', {'default_value' => []}),
){

    $targets_path = '/srv/prometheus/beta/targets'
    $rules_path = '/srv/prometheus/beta/rules'

    # one job per varnish cache 'role'
    $varnish_jobs = [
      {
        'job_name'        => 'varnish-text',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/varnish-text_*.yaml"] },
        ]
      },
      {
        'job_name'        => 'varnish-upload',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/varnish-upload_*.yaml"] },
        ]
      },
    ]

    $mysql_jobs = [
      {
        'job_name'        => 'mysql-core',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/mysql-core_*.yaml"] },
        ]
      },
    ]

    $cassandra_jobs = [
      {
        'job_name'        => 'cassandra-restbase',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/cassandra-restbase_*.yaml"] },
        ]
      },
    ]

    $web_jobs = [
      {
        'job_name'        => 'apache',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/apache_*.yaml"] },
        ]
      },
      {
        'job_name'        => 'memcache',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/memcache_*.yaml"] },
        ]
      },
    ]

    $jmx_exporter_jobs = [
        {
            'job_name'        => 'jmx_kafka',
            'scheme'          => 'http',
            'scrape_timeout'  => '45s',
            'file_sd_configs' => [
                { 'files' => [ "${targets_path}/jmx_kafka_broker_*.yaml" ]}
            ],
        },
        {
            'job_name'        => 'jmx_kafka_mirrormaker',
            'scheme'          => 'http',
            'file_sd_configs' => [
                { 'files' => [ "${targets_path}/jmx_kafka_mirrormaker_*.yaml" ]}
            ],
        },
    ]

    # Job definition for memcache_exporter
    $memcached_jobs = [
      {
        'job_name'        => 'memcached',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/memcached_*.yaml"] },
        ]
      },
    ]

    $mcrouter_jobs = [
      {
        'job_name'        => 'mcrouter',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/mcrouter_*.yaml"] },
        ]
      },
    ]
    prometheus::class_config{ "memcached_${::site}":
        dest       => "${targets_path}/memcached_${::site}.yaml",
        class_name => 'profile::prometheus::memcached_exporter',
        port       => 9150,
        labels     => {}
    }

    prometheus::class_config{ "mcrouter_${::site}":
        dest       => "${targets_path}/mcrouter_${::site}.yaml",
        class_name => 'profile::prometheus::mcrouter_exporter',
        port       => 9151,
        labels     => {}
    }

    # Collect all declared kafka_broker_.* jmx_exporter_instances
    # from any uses of profile::kafka::broker::monitoring.
    prometheus::jmx_exporter_config{ "kafka_broker_${::site}":
        dest              => "${targets_path}/jmx_kafka_broker_beta_${::site}.yaml",
        class_name        => 'profile::kafka::broker::monitoring',
        instance_selector => 'kafka_broker_.*',
    }
    # Collect all declared kafka_mirror_.* jmx_exporter_instances
    # from any uses of profile::kafka::mirror.
    prometheus::jmx_exporter_config{ "kafka_mirrormaker_${::site}":
        dest              => "${targets_path}/jmx_kafka_mirrormaker_beta_${::site}.yaml",
        class_name        => 'profile::kafka::mirror',
        instance_selector => 'kafka_mirror_.*',
    }

    prometheus::server { 'beta':
        listen_address       => '127.0.0.1:9903',
        external_url         => 'https://beta-prometheus.wmflabs.org/beta',
        scrape_configs_extra => [
          $varnish_jobs, $mysql_jobs, $web_jobs, $cassandra_jobs,
          $jmx_exporter_jobs, $memcached_jobs, $mcrouter_jobs
        ].flatten,
        storage_retention    => $storage_retention,
        alertmanagers        => $alertmanagers.map |$a| { "${a}:9093" },
    }

    prometheus::web { 'beta':
        proxy_pass => 'http://127.0.0.1:9903/beta',
        homepage   => true,
    }

    prometheus::rule { 'rules_beta.yml':
        instance => 'beta',
        source   => 'puppet:///modules/role/prometheus/rules_beta.yml',
    }

    prometheus::rule { 'alerts_beta.yml':
        instance => 'beta',
        source   => 'puppet:///modules/role/prometheus/alerts_beta.yml',
    }

    $targets_file = "${targets_path}/node_project.yml"

    include ::prometheus::wmcs_scripts

    cron { 'prometheus_labs_project_targets':
        ensure  => present,
        command => "/usr/local/bin/prometheus-labs-targets > ${targets_file}.$$ && mv ${targets_file}.$$ ${targets_file}",
        minute  => '*/10',
        hour    => '*',
        user    => 'prometheus',
    }
}