Puppet Class: profile::rsyslog::kafka_shipper

Defined in:
modules/profile/manifests/rsyslog/kafka_shipper.pp

Overview

Parameters:

  • enable (Boolean) (defaults to: lookup('profile::rsyslog::kafka_shipper::enable'))
  • queue_enabled_sites (Array[String]) (defaults to: lookup('profile::rsyslog::kafka_queue_enabled_sites'))
  • kafka_destination_clusters (Hash) (defaults to: lookup('profile::rsyslog::kafka_destination_clusters'))


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
65
66
67
68
69
70
71
72
# File 'modules/profile/manifests/rsyslog/kafka_shipper.pp', line 7

class profile::rsyslog::kafka_shipper (
    Boolean       $enable                     = lookup('profile::rsyslog::kafka_shipper::enable'),
    Array[String] $queue_enabled_sites        = lookup('profile::rsyslog::kafka_queue_enabled_sites'),
    Hash          $kafka_destination_clusters = lookup('profile::rsyslog::kafka_destination_clusters'),
) {

    # use kafka_config to build the ssl broker string to be used in the rsyslog omkafka configs for our site
    # clusters are defined under kafka_clusters in hieradata/common.yaml
    if $enable {
        $config                = kafka_config($kafka_destination_clusters[$::site])
        $logging_kafka_brokers = split($config['brokers']['ssl_string'], ',')
    }

    ensure_packages('rsyslog-kafka')

    $ensure = $enable.bool2str('present', 'absent')

    $queue_size = $::site in $queue_enabled_sites ? {
        true  => 10000,
        false => 0,
    }

    file { '/etc/rsyslog.lookup.d':
        ensure => directory,
    }

    file { '/etc/rsyslog.lookup.d/lookup_table_output.json':
        ensure  => stdlib::ensure($ensure, 'file'),
        source  => 'puppet:///modules/profile/rsyslog/lookup_table_output.json',
        require => File['/etc/rsyslog.lookup.d'],
        notify  => Service['rsyslog'],
    }

    # Rsyslog defaults to a MaxMessageSize of 8k which is too short for certain
    # types of logs (for instance multi-line events containing stack traces),
    # increase to 64k to avoid dropping large logs to the floor.
    rsyslog::global_entry('maxMessageSize', '64k')

    rsyslog::conf { 'lookup_output':
        ensure   => $ensure,
        content  => template('profile/rsyslog/lookup_output.conf.erb'),
        priority => 10,
        require  => File['/etc/rsyslog.lookup.d/lookup_table_output.json'],
    }

    rsyslog::conf { 'template_syslog_json':
        ensure   => $ensure,
        source   => 'puppet:///modules/profile/rsyslog/template_syslog_json.conf',
        priority => 10,
    }

    include profile::base::certificates
    $trusted_ca_path = $profile::base::certificates::trusted_ca_path
    rsyslog::conf { 'output_kafka':
        ensure   => $ensure,
        content  => template('profile/rsyslog/output_kafka.conf.erb'),
        priority => 30,
    }

    rsyslog::conf { 'output_local':
        ensure   => $ensure,
        content  => template('profile/rsyslog/output_local.conf.erb'),
        priority => 95,
    }

}