Puppet Class: cassandra::metrics

Defined in:
modules/cassandra/manifests/metrics.pp

Overview

Parameters:

  • graphite_prefix (Any) (defaults to: "cassandra.${::hostname}")
  • graphite_host (Any) (defaults to: 'localhost')
  • graphite_port (Any) (defaults to: '2003')
  • blacklist (Any) (defaults to: undef)
  • whitelist (Any) (defaults to: undef)
  • ensure (Any) (defaults to: present)


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
# File 'modules/cassandra/manifests/metrics.pp', line 28

class cassandra::metrics(
    $graphite_prefix = "cassandra.${::hostname}",
    $graphite_host   = 'localhost',
    $graphite_port   = '2003',
    $blacklist       = undef,
    $whitelist       = undef,
    $ensure          = present,
) {
    validate_string($graphite_prefix)
    validate_string($graphite_host)
    validate_string($graphite_port)
    if $blacklist {
        validate_array($blacklist)
    }
    if $whitelist {
        validate_array($whitelist)
    }

    $target_cassandra_version = $::cassandra::target_version

    $filter_file   = '/etc/cassandra-metrics-collector/filter.yaml'
    $collector_jar = '/usr/local/lib/cassandra-metrics-collector/cassandra-metrics-collector.jar'

    # Backward incompatible changes to cassandra-metrics-collector were needed
    # to support Cassandra 2.2 and 3.x; Use the apropos version of the collector.
    if $target_cassandra_version == '2.1' {
        $collector_version = '2.1.1-20160520.211019-1'
    } elsif $target_cassandra_version == '2.2' {
        $collector_version = '3.1.4-20170427.001104-1'
    } else {
        $collector_version = '4.1.0'
    }

    scap::target { 'cassandra/metrics-collector':
        deploy_user  => 'deploy-service',
        manage_user  => true,
        service_name => 'cassandra-metrics-collector',
    }

    $ensure_directory = $ensure ? {
        absent  => $ensure,
        default => 'directory',
    }

    $ensure_link = $ensure ? {
        absent  => $ensure,
        default => 'link',
    }

    file { '/etc/cassandra-metrics-collector':
        ensure => $ensure_directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { $filter_file:
        ensure  => $ensure,
        content => template("${module_name}/metrics-filter.yaml.erb"),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
    }

    file { '/usr/local/lib/cassandra-metrics-collector':
        ensure => $ensure_directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { $collector_jar:
        ensure  => $ensure_link,
        target  => "/srv/deployment/cassandra/metrics-collector/lib/cassandra-metrics-collector-${collector_version}-jar-with-dependencies.jar",
        require => Scap::Target['cassandra/metrics-collector'],
    }

    cron { 'cassandra-metrics-collector':
        ensure => absent,
        user   => 'cassandra',
    }

    systemd::service { 'cassandra-metrics-collector':
        ensure  => $ensure,
        content => systemd_template('cassandra-metrics-collector'),
        restart => true,
        require => [
            File[$collector_jar],
            File[$filter_file],
        ],
    }

    base::service_auto_restart { 'cassandra-metrics-collector':
        ensure => $ensure,
    }

    # built-in cassandra metrics reporter, T104208
    file { '/usr/share/cassandra/lib/metrics-graphite.jar':
        ensure => absent,
    }

    file { '/etc/cassandra/metrics.yaml':
        ensure => absent,
    }
}