Puppet Class: statistics::wmde::graphite

Defined in:
modules/statistics/manifests/wmde/graphite.pp

Overview

Licence AGPL version 3 or later

These scripts get metrics from a variety of places including:

- Databases
- Log files
- Hive
- Dumps

And send the data to statsd or graphite directly

Parameters

dir           - string. Directory to use.
user          - string. User to run scripts as.
statsd_host   - string. Host to use for statsd data.
graphite_host - string. Host to use for graphite data.
wmde_secrets

Parameters:

  • dir (Any)
  • user (Any)
  • statsd_host (Any)
  • graphite_host (Any)
  • wmde_secrets (Any)

Author:

  • Addshore



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
# File 'modules/statistics/manifests/wmde/graphite.pp', line 19

class statistics::wmde::graphite(
    $dir,
    $user,
    $statsd_host,
    $graphite_host,
    $wmde_secrets,
) {

    $scripts_dir  = "${dir}/src/scripts"

    ensure_packages([
        'php',
        'php-cli',
        'php-xml'
    ])

    include ::passwords::mysql::research
    # This file will render at
    # /etc/mysql/conf.d/research-wmde-client.cnf.
    mariadb::config::client { 'research-wmde':
        user    => $::passwords::mysql::research::user,
        pass    => $::passwords::mysql::research::pass,
        group   => $user,
        mode    => '0440',
        require => User[$user],
    }

    $directories = [
        $dir,
        "${dir}/src",
        "${dir}/data",
    ]

    file { $directories:
        ensure  => 'directory',
        owner   => $user,
        group   => $user,
        mode    => '0644',
        require => User[$user],
    }

    git::clone { 'wmde/scripts':
        ensure    => 'latest',
        branch    => 'production',
        directory => $scripts_dir,
        origin    => 'https://gerrit.wikimedia.org/r/analytics/wmde/scripts',
        owner     => $user,
        group     => $user,
        require   => File["${dir}/src"],
    }

    git::clone { 'wmde/toolkit-analyzer-build':
        ensure    => 'latest',
        branch    => 'production',
        directory => "${dir}/src/toolkit-analyzer-build",
        origin    => 'https://gerrit.wikimedia.org/r/analytics/wmde/toolkit-analyzer-build',
        owner     => $user,
        group     => $user,
        require   => File["${dir}/src"],
    }

    file { "${dir}/src/config":
        ensure  => 'file',
        owner   => 'root',
        group   => $user,
        mode    => '0440',
        content => template('statistics/wmde/config.erb'),
        require => File["${dir}/src"],
    }

    systemd::timer::job { 'wmde-analytics-minutely':
        ensure              => present,
        description         => 'Minutely jobs for wmde analytics infrastructure',
        user                => $user,
        command             => "${scripts_dir}/cron/minutely.sh ${scripts_dir}",
        require             => Git::Clone['wmde/scripts'],
        interval            => {'start' => 'OnCalendar', 'interval' => '*-*-* *:*:0'},
        max_runtime_seconds => 55,  # kill if still running after 55s
    }

    # Note: some of the scripts run by this cron need access to secrets!
    # Docs can be seen at https://github.com/wikimedia/analytics-wmde-scripts/blob/master/README.md
    systemd::timer::job { 'wmde-analytics-daily-early':
        ensure              => present,
        description         => 'Daily jobs for wmde analytics infrastructure',
        user                => $user,
        command             => "/usr/bin/time ${scripts_dir}/cron/daily.03.sh ${scripts_dir}",
        require             => [
            Git::Clone['wmde/scripts'],
            File["${dir}/src/config"],
            Mariadb::Config::Client['research-wmde'],
        ],
        interval            => {'start' => 'OnCalendar', 'interval' => '*-*-* 3:0:0'},
        max_runtime_seconds => 72000,  # kill if still running after 20h
    }

    systemd::timer::job { 'wmde-analytics-daily-noon':
        ensure              => present,
        description         => 'Daily jobs for wmde analytics infrastructure',
        user                => $user,
        command             => "/usr/bin/time ${scripts_dir}/cron/daily.12.sh ${scripts_dir}",
        require             => [
            Git::Clone['wmde/scripts'],
            File["${dir}/src/config"],
            Mariadb::Config::Client['research-wmde'],
        ],
        interval            => {'start' => 'OnCalendar', 'interval' => '*-*-* 12:0:0'},
        max_runtime_seconds => 72000,  # kill if still running after 20h
    }

    systemd::timer::job { 'wmde-analytics-weekly':
        ensure              => present,
        description         => 'Weekly jobs for wmde analytics infrastructure',
        user                => $user,
        command             => "/usr/bin/time ${scripts_dir}/cron/weekly.sh ${scripts_dir}",
        require             => [
            Git::Clone['wmde/scripts'],
            File["${dir}/src/config"],
        ],
        interval            => {'start' => 'OnCalendar', 'interval' => 'Sunday 0:0:0'},
        max_runtime_seconds => 518400,  # kill if still running after 6d
    }

    # Disabled until T278665 is solved
    systemd::timer::job { 'wmde-toolkit-analyzer-build':
        ensure      => absent,
        description => 'Daily jobs for rebuilding wmde analyzor toolkit',
        user        => $user,
        command     => "/usr/bin/java -Dhttp.proxyHost=\"http://webproxy.${::site}.wmnet\" -Dhttp.proxyPort=8080 -Xmx2g -jar ${dir}/src/toolkit-analyzer-build/toolkit-analyzer.jar --processors Metric --store ${dir}/data --latest",
        interval    => {'start' => 'OnCalendar', 'interval' => '*-*-* 12:0:0'},
    }

}