Puppet Class: logstash

Defined in:
puppet/modules/logstash/manifests/init.pp

Overview

Class: logstash

Logstash is a flexible log aggregation framework built on top of Elasticsearch, a distributed document store. It lets you configure logging pipelines that ingress log data from various sources in a variety of formats.

Parameters:

  • $heap_memory_mb: amount of memory to allocate to logstash in megabytes.

  • $pipeline_workers: number of worker threads to run to use for

    filter/output processing

Sample usage:

class { 'logstash':
    heap_memory_mb => 128,
    pipeline_workers => 3,
}

Parameters:

  • heap_memory_mb (Any)
  • pipeline_workers (Any)


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
# File 'puppet/modules/logstash/manifests/init.pp', line 19

class logstash(
    $heap_memory_mb,
    $pipeline_workers,
) {
    require ::elasticsearch::repository

    require_package('openjdk-8-jre-headless')

    package { 'logstash':
        ensure  => latest,
        require => Package['openjdk-8-jre-headless'],
    }

    # JRuby waits for enough entropy from /dev/random when starting up. Especially
    # within VM's very little entropy may be available. haveged adds an entropy source
    # to fix this problem.
    package { 'haveged':
        ensure => present,
        before => Service['logstash']
    }
    Package['haveged'] -> Logstash::Plugin <| |>

    file { '/etc/logstash/conf.d':
        ensure  => directory,
        recurse => true,
        purge   => true,
        force   => true,
        source  => 'puppet:///modules/logstash/conf.d',
        require => Package['logstash'],
    }

    file { '/etc/logstash/logstash.yml':
        ensure  => file,
        content => ordered_yaml({
            'path.data'        => '/var/lib/logstash',
            'path.config'      => '/etc/logstash/conf.d',
            'path.logs'        => '/var/log/logstash',
            'pipeline.workers' => $pipeline_workers,
        }),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        require => Package['logstash'],
        before  => Service['logstash'],
        notify  => Service['logstash'],
    }

    file { '/etc/logstash/jvm.options':
        ensure  => file,
        content => template('logstash/jvm.options.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        require => Package['logstash'],
        notify  => Service['logstash'],
    }

    service { 'logstash':
        ensure   => running,
        provider => 'systemd',
        enable   => true,
        require  => [
            Package['logstash'],
            File['/etc/logstash/jvm.options']
        ]
    }
}