Notice that java, elasticsearch and rabbitmq are already set up in my system.
{
"name": "logstash-server",
"json_class": "Chef::Role",
"run_list": [
"logstash::server"
],
"description": "",
"chef_type": "role",
"override_attributes": {
"logstash": {
"instance": {
"server": {
"xms": "256M",
"xmx": "1024M",
"elasticsearch_ip": "127.0.0.1",
"config_templates_cookbook": "logstash-local",
"config_templates": {
"input_rabbitmq": "config/input_rabbitmq.conf.erb",
"output_elasticsearch": "config/output_elasticsearch.conf.erb"
},
"config_templates_variables": {
"elasticsearch_ip": "127.0.0.1",
"elasticsearch_cluster": "crabtastic",
"rabbitmq_host": "rabbithost01",
"rabbitmq_vhost": "production",
"rabbitmq_user": "john",
"rabbitmq_password": "acme"
}
}
}
}
}
}
Notice that the config references a logstash-local
cookbook. The default recipe have a couple
of generic config, but we need more. This is where I keep my .conf.erb
.
$ mkdir site-coobooks/logstash-local
$ cp -R cookbooks/logstash/templates site-cookbooks/logstash-local
$ cat > site-cookbooks/logstash-local/metadata.rb
name 'logstash-local'
description 'templates for logstash config'
^D
Templates are now in site-cookbooks/logstash-local/templates/default/config/
For completeness here's my version of input_rabbitmq.conf.erb
input {
rabbitmq {
exchange => "logstash"
durable => true
<% if @rabbitmq_host -%>
host => "<%= @rabbitmq_host %>"
<% end -%>
<% if @rabbitmq_vhost -%>
vhost => "<%= @rabbitmq_vhost %>"
<% end -%>
<% if @rabbitmq_user -%>
user => "<%= @rabbitmq_user %>"
<% end -%>
<% if @rabbitmq_password -%>
password => "<%= @rabbitmq_password %>"
<% end -%>
}
}