Puppet Class: role::prometheus::beta

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

Overview

Parameters:

  • storage_retention (Any) (defaults to: hiera('prometheus::server::storage_retention', '730h'))
  • prometheus_v2 (Any) (defaults to: hiera('prometheus::server::prometheus_v2', false))


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
# File 'modules/role/manifests/prometheus/beta.pp', line 8

class role::prometheus::beta (
    $storage_retention = hiera('prometheus::server::storage_retention', '730h'),
    $prometheus_v2 = hiera('prometheus::server::prometheus_v2', false),
) {

    class { '::httpd':
        modules => ['proxy', 'proxy_http'],
    }

    $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'        => 'hhvm',
        'file_sd_configs' => [
          { 'files' => [ "${targets_path}/hhvm_*.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" ]}
            ],
        },
    ]

    # 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_.*',
        site              => $::site,
    }
    # 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_.*',
        site              => $::site,
    }

    prometheus::server { 'beta':
        listen_address       => '127.0.0.1:9903',
        external_url         => 'https://beta-prometheus.wmflabs.org/beta',
        scrape_configs_extra => array_concat($varnish_jobs, $mysql_jobs, $web_jobs,
            $cassandra_jobs, $jmx_exporter_jobs),
        storage_retention    => $storage_retention,
        prometheus_v2        => $prometheus_v2,
    }

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

    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',
    }
}