Skip to content

Commit

Permalink
rework logstash
Browse files Browse the repository at this point in the history
  • Loading branch information
dearing committed Jul 27, 2015
1 parent a0dbc6c commit ccf120d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 102 deletions.
39 changes: 38 additions & 1 deletion libraries/provider_logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ class Logstash < Chef::Provider::LWRPBase
provides :logstash

service_name = 'logstash'

action :install do
home_dir = "/opt/logstash/logstash-#{new_resource.version}"

user new_resource.user
group new_resource.group

directory "#{home_dir}/config" do
owner new_resource.user
group new_resource.group
mode '0755'
action :create
end

ark service_name do
checksum new_resource.checksum
group new_resource.group
Expand All @@ -21,11 +29,40 @@ class Logstash < Chef::Provider::LWRPBase
version new_resource.version
end

template "#{home_dir}/config/logging.yml" do
source 'logstash/logging.yml.erb'
owner 'root'
group 'root'
mode '0644'
cookbook new_resource.source
end

template "#{home_dir}/config/logstash.conf" do
source 'logstash/logstash.conf.erb'
owner 'root'
group 'root'
mode '0644'
cookbook new_resource.source
variables options: {
'port' => new_resource.port,
'key' => new_resource.key,
'crt' => new_resource.crt,
'key_location' => new_resource.key_location,
'crt_location' => new_resource.crt_location
}
end

runit_service service_name do
default_logger true
owner new_resource.user
group new_resource.user
cookbook new_resource.source
options new_resource.runit_options.merge(
'home_dir' => home_dir,
'user' => new_resource.user,
'group' => new_resource.group,
'config_file' => 'config/logstash.conf'
)
action [:create, :enable]
end
end
Expand Down
79 changes: 0 additions & 79 deletions libraries/provider_logstash_config.rb

This file was deleted.

12 changes: 5 additions & 7 deletions libraries/resource_logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ class Logstash < Chef::Resource::LWRPBase
attribute :owner, kind_of: String, default: 'logstash'

attribute :path, kind_of: String, default: '/opt/logstash'
end

class LogstashConfig < Chef::Resource::LWRPBase
resource_name :logstash_config
default_action :create
actions [:create, :delete]

attribute :crt, kind_of: String, default: ''
attribute :crt_location, kind_of: String, default: '/etc/logstash/logstash.crt'
Expand All @@ -50,7 +44,11 @@ class LogstashConfig < Chef::Resource::LWRPBase
attribute :ls_use_gc_logging, kind_of: [TrueClass, FalseClass], default: true
attribute :ls_user, kind_of: String, default: 'logstash'
attribute :port, kind_of: Integer, default: 5043
attribute :source, kind_of: String, default: 'elk'

# RUNIT
attribute :runit_args, kind_of: Hash, default: {}
attribute :runit_options, kind_of: Hash, default: {}
attribute :runit_env, kind_of: Hash, default: {}
end
end
end
8 changes: 0 additions & 8 deletions templates/default/logstash/conf.d/00-input.conf.erb

This file was deleted.

4 changes: 0 additions & 4 deletions templates/default/logstash/conf.d/99-output.conf.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
input {
lumberjack {
port => "<%= @options['port'] %>"
type => "logs"
ssl_certificate => "<%= @options['crt_location'] %>"
ssl_key => "<%= @options['key_location'] %>"
}
}

filter {
if [type] == "syslog" {
grok {
Expand All @@ -10,4 +19,9 @@ filter {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
}
}

output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}
5 changes: 3 additions & 2 deletions templates/default/sv-logstash-run.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

cd /home/logstash
cd <%= @options['home_dir'] %>
exec 2>&1

exec /usr/bin/env logstash -c /etc/logstash/config
chpst -u :<%= @options['user'] %>:<%= @options['group'] %>
exec ./bin/logstash -f <%= @options['config_file'] %>

0 comments on commit ccf120d

Please sign in to comment.