Puppet Class: profile::prometheus::ops_mysql

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

Overview

Uses addendum to prometheus::ops to add the mysql specific configuration

Parameters:

  • targets_path (Any) (defaults to: lookup('prometheus::server::target_path', String, 'first', '/srv/prometheus/ops/targets'))
  • mysql_host (Any) (defaults to: lookup('prometheus::server::mysqld_exporter::mysql::host', String, 'first', 'UNDEFINED'))
  • mysql_port (Any) (defaults to: lookup('prometheus::server::mysqld_exporter::mysql::port', Integer, 'first', 3306))
  • mysql_database (Any) (defaults to: lookup('prometheus::server::mysqld_exporter::mysql::database', String, 'first', ''))
  • mysql_user (Any) (defaults to: lookup('prometheus::server::mysqld_exporter::mysql::user', String, 'first', ''))
  • mysql_password (Any) (defaults to: lookup('prometheus::server::mysqld_exporter::mysql::password', String, 'first', ''))


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
# File 'modules/profile/manifests/prometheus/ops_mysql.pp', line 2

class profile::prometheus::ops_mysql (
    $targets_path = lookup('prometheus::server::target_path', String, 'first', '/srv/prometheus/ops/targets'),
    $mysql_host = lookup('prometheus::server::mysqld_exporter::mysql::host', String, 'first', 'UNDEFINED'),
    $mysql_port = lookup('prometheus::server::mysqld_exporter::mysql::port', Integer, 'first', 3306),
    $mysql_database = lookup('prometheus::server::mysqld_exporter::mysql::database', String, 'first', ''),
    $mysql_user = lookup('prometheus::server::mysqld_exporter::mysql::user', String, 'first', ''),
    $mysql_password = lookup('prometheus::server::mysqld_exporter::mysql::password', String, 'first', ''),
) {
    # Generate configuration files for mysql jobs by querying zarcillo
    # Do not apply it on pops (role != prometheus), as they are outdated and do not hold
    # any production database
    if $mysql_host != 'UNDEFINED' {
        require_package (
            'python3-pymysql',
            'python3-yaml',
        )
        file { '/etc/prometheus/zarcillo.cnf':
            content   => template('profile/prometheus/zarcillo.cnf.erb'),
            mode      => '0400',
            show_diff => false,
        }
        file { '/usr/local/sbin/mysqld_exporter_config.py':
            source => 'puppet:///modules/profile/prometheus/mysqld_exporter_config.py',
            mode   => '0555',
        }
        systemd::timer::job{'generate-mysqld-exporter-config':
            ensure      => 'present',
            description => 'generates prometheus-mysqld-exporter targets from zarcillo',
            user        => 'root',
            command     => "/usr/local/sbin/mysqld_exporter_config.py ${::site} '${targets_path}'",
            interval    => {
                'start'    => 'OnCalendar',
                'interval' => '*-*-* *:00/30:00', # every 30 min
            },
            require     => [
                File['/etc/prometheus/zarcillo.cnf', '/usr/local/sbin/mysqld_exporter_config.py'],
                Package['python3-pymysql', 'python3-yaml'],
            ],
        }
    }

}