Puppet Class: logstash::output::elasticsearch

Defined in:
puppet/modules/logstash/manifests/output/elasticsearch.pp

Overview

Class: logstash::output::elasticsearch

Configure logstash to output to elasticsearch

Parameters:

  • $host: Elasticsearch server. Default '127.0.0.1'.

  • $index: Index to write events to. Default 'logstash-%+YYYY+YYYY.MM+YYYY.MM.dd'.

  • $port: Elasticsearch server port. Default 9200.

  • $require_tag: Tag to require on events. Default undef.

  • $manage_indices: Whether cron jobs should be installed to manage

    Elasticsearch indices. Default false.
    
  • $priority: Configuration loading priority. Default undef.

  • $ensure: Whether the config should exist. Default present.

Sample usage:

class { 'logstash::output::elasticsearch':
    host           => '127.0.0.1',
    require_tag    => 'es',
    manage_indices => 'true',
}

Parameters:

  • ensure (Any) (defaults to: present)
  • host (Any) (defaults to: '127.0.0.1')
  • index (Any) (defaults to: 'logstash-%{+YYYY.MM.dd}')
  • port (Any) (defaults to: 9200)
  • require_tag (Any) (defaults to: undef)
  • manage_indices (Any) (defaults to: false)
  • priority (Any) (defaults to: undef)


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

class logstash::output::elasticsearch(
    $ensure              = present,
    $host                = '127.0.0.1',
    $index               = 'logstash-%{+YYYY.MM.dd}',
    $port                = 9200,
    $require_tag         = undef,
    $manage_indices      = false,
    $priority            = undef,
) {
    package { 'elasticsearch-curator':
        ensure   => 'present',
        provider => 'pip',
    }

    logstash::conf{ 'output-elasticsearch':
        ensure   => $ensure,
        content  => template('logstash/output/elasticsearch.erb'),
        priority => $priority,
    }

    $ensure_cron = $manage_indices ? {
        true    => 'present',
        default => 'absent',
    }

    cron { 'logstash_delete_index':
        ensure  => $ensure_cron,
        command => "/usr/local/bin/curator delete --host ${host} --port ${port} --timestring '%Y.%m.%d' --older-than 15",
        user    => 'root',
        hour    => 0,
        minute  => 42,
        require => Package['elasticsearch-curator'],
    }

    cron { 'logstash_optimize_index':
        ensure  => $ensure_cron,
        command => "/usr/local/bin/curator optimize --host ${host} --port ${port} --timestring '%Y.%m.%d' --older-than 2",
        user    => 'root',
        hour    => 1,
        minute  => 5,
        require => Package['elasticsearch-curator'],
    }
}