Skip to content

Instantly share code, notes, and snippets.

@algesten
Last active August 29, 2015 14:14
Show Gist options
  • Save algesten/60e532d938111e8d4eec to your computer and use it in GitHub Desktop.
Save algesten/60e532d938111e8d4eec to your computer and use it in GitHub Desktop.
install logstash with lusis/chef-logstash 0.11.2

install logstash with lusis/chef-logstash 0.11.2

My json config file

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"
                    }
                }
            }
        }
    }
}

The local cookbook

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/

My rabbit conf template

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 -%>
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment