Defined Type: logstash::output::elasticsearch
- Defined in:
- modules/logstash/manifests/output/elasticsearch.pp
Overview
Define: logstash::output::elasticsearch
Configure logstash to output to elasticsearch
Parameters:
-
$ensure: Whether the config should exist. Default present.
-
$host: Elasticsearch server. Default '127.0.0.1'.
-
$index: Index to write events to. Default '$title-%+YYYY+YYYY.MM+YYYY.MM.dd'.
-
$prefix: indices with this prefix will be cleaned up. Used by the
`cleanup.yaml.erb` template.
-
$port: Elasticsearch server port. Default 9200.
-
$guard_condition: Logstash condition to require to pass events to output.
Default undef.
-
$manage_indices: Whether cron jobs should be installed to manage
elasticsearch indices. Default false.
-
$priority: Configuration loading priority. Default 10.
-
$template: Path to Elasticsearch mapping template. Default undef.
-
$template_name: Name of Elasticsearch mapping template.
Default $title.
-
$plugin_id: Name associated with Logstash metrics
Sample usage:
logstash::output::elasticsearch { 'logstash':
host => '127.0.0.1',
guard_condition => '"es" in [tags]',
manage_indices => true,
}
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 |
# File 'modules/logstash/manifests/output/elasticsearch.pp', line 30
define logstash::output::elasticsearch(
$ensure = present,
$host = '127.0.0.1',
$index = "${title}-%{+YYYY.MM.dd}",
$prefix = "${title}-",
$port = 9200,
$guard_condition = undef,
$manage_indices = false,
$priority = 10,
$template = undef,
$template_name = $title,
$plugin_id = "output/elasticsearch/${title}",
$cleanup_template = 'logstash/curator/cleanup.yaml.erb',
) {
require ::logstash::output::elasticsearch::scripts
logstash::conf{ "output-elasticsearch-${title}":
ensure => $ensure,
content => template('logstash/output/elasticsearch.erb'),
priority => $priority,
}
$ensure_cron = $manage_indices ? {
true => 'present',
default => 'absent'
}
# curator cluster config template require a list of hosts
$http_port = $port
$cluster_name = $title
$curator_hosts = [ $host ]
elasticsearch::curator::config {
"config-${title}":
content => template('elasticsearch/curator_cluster.yaml.erb');
"cleanup_${title}":
content => template($cleanup_template)
}
cron { "logstash_cleanup_indices_${title}":
ensure => $ensure_cron,
command => "/usr/bin/curator --config /etc/curator/config-${title}.yaml /etc/curator/cleanup_${title}.yaml > /dev/null",
user => 'root',
hour => 0,
minute => 42,
require => Elasticsearch::Curator::Config["cleanup_${title}"],
}
}
|