Puppet Class: profile::logstash::apifeatureusage

Defined in:
modules/profile/manifests/logstash/apifeatureusage.pp

Overview

SPDX-License-Identifier: Apache-2.0 vim:sw=4 ts=4 sts=4 et:

Class: profile::logstash::apifeatureusage

Extension:ApiFeatureUsage into Elasticsearch.

Parameters:

  • targets (Array[Stdlib::Host]) (defaults to: lookup('profile::logstash::apifeatureusage::targets'))
  • curator_actions (Hash) (defaults to: lookup('profile::logstash::apifeatureusage::curator_actions'))
  • jobs_host (Optional[Stdlib::Fqdn]) (defaults to: lookup('profile::logstash::apifeatureusage::jobs_host', { default_value => undef }))


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
# File 'modules/profile/manifests/logstash/apifeatureusage.pp', line 7

class profile::logstash::apifeatureusage(
    Array[Stdlib::Host]    $targets         = lookup('profile::logstash::apifeatureusage::targets'),
    Hash                   $curator_actions = lookup('profile::logstash::apifeatureusage::curator_actions'),
    Optional[Stdlib::Fqdn] $jobs_host       = lookup('profile::logstash::apifeatureusage::jobs_host', { default_value => undef }),
) {
    include profile::logstash::collector

    # Template for Elasticsearch index creation
    # lint:ignore:puppet_url_without_modules
    file { '/etc/logstash/apifeatureusage-template.json':
        ensure => present,
        source => 'puppet:///modules/profile/logstash/apifeatureusage-template.json',
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
    }
    # lint:endignore

    # Add configuration to logstash
    # Needs to come after 'filter_mediawiki' (priority 50)
    logstash::conf { 'filter_apifeatureusage':
        source   => 'puppet:///modules/profile/logstash/filter-apifeatureusage.conf',
        priority => 55,
    }

    $targets.each |Stdlib::Host $cluster| {
        logstash::output::elasticsearch { "apifeatureusage-${cluster}":
            host            => $cluster,
            index           => 'apifeatureusage-%{+YYYY.MM.dd}',
            guard_condition => '[type] == "api-feature-usage-sanitized"',
            priority        => 95,
            template        => '/etc/logstash/apifeatureusage-template.json',
            require         => File['/etc/logstash/apifeatureusage-template.json'],
        }

        # TODO: this curator config and job ought to run on the search cluster
        # It is here to maintain functionality until it can be moved
        $dc = $cluster.split('[.]')[-2]
        $cluster_name = "production-search-${dc}"
        $curator_hosts = [$cluster]
        $http_port = 9200
        if $jobs_host == $::fqdn {
            elasticsearch::curator::config { $cluster_name:
                content => template('elasticsearch/curator_cluster.yaml.erb'),
            }

            elasticsearch::curator::job { "apifeatureusage_${dc}":
                cluster_name => $cluster_name,
                actions      => $curator_actions,
            }
        } else {
            elasticsearch::curator::job { "apifeatureusage_${dc}":
                ensure       => 'absent',
                cluster_name => $cluster_name,
            }
        }
    }
}