Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify custom_logstash setup #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ CentOS 6.5
<td><tt>lumberjack</tt></td>
</tr>
<tr>
<td><tt>['elkstack']['config']['custom_logstash']['name']</tt></td>
<td>Array of strings</td>
<td><tt>['elkstack']['config']['custom_logstash']</tt></td>
<td>Hash</td>
<td>See `attributes/logstash.rb` for an explanation of how to use this attribute to populate additional logstash configuration file templates</td>
<td><tt>[]</tt></td>
</tr>
Expand Down
11 changes: 5 additions & 6 deletions attributes/logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@
server['config_templates_variables'] = config_templates_variables

# arbitrary data structure for any arbitrary logstash config
default_unless['elkstack']['config']['custom_logstash']['name'] = []
default_unless['elkstack']['config']['custom_logstash'] = {}
# Currently for arbitrary logstash configs, the recipe that sets up the logstash file should add:
# node.default['elkstack']['config']['custom_logstash']['name'].push('<service_name>')
# and then populate node['elkstack']['config']['custom_logstash'][service_name][setting] with your values
# default['elkstack']['config']['custom_logstash'][<name>]['name'] = 'my_logstashconfig'
# default['elkstack']['config']['custom_logstash'][<name>]['source'] = 'my_logstashconfig.conf.erb'
# default['elkstack']['config']['custom_logstash'][<name>]['cookbook'] = 'your_cookbook'
# default['elkstack']['config']['custom_logstash'][<name>]['variables'] = { :warning => 'foo' }
# and then populate node['elkstack']['config']['custom_logstash'][source_filename][setting] with your values
# default['elkstack']['config']['custom_logstash']['my_logstashconfig']['source'] = 'my_logstashconfig_alt.conf.erb'
# default['elkstack']['config']['custom_logstash']['my_logstashconfig']['cookbook'] = 'your_cookbook'
# default['elkstack']['config']['custom_logstash']['my_logstashconfig']['variables'] = { :warning => 'foo' }
9 changes: 4 additions & 5 deletions recipes/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@
end

# install additional stacks logstash configuration
node['elkstack']['config']['custom_logstash']['name'].each do |logcfg|
logcfg_name = node['elkstack']['config']['custom_logstash'][logcfg]['name']
logcfg_source = node['elkstack']['config']['custom_logstash'][logcfg]['source']
logcfg_cookbook = node['elkstack']['config']['custom_logstash'][logcfg]['cookbook']
logcfg_variables = node['elkstack']['config']['custom_logstash'][logcfg]['variables']
node['elkstack']['config']['custom_logstash'].keys.each do |logcfg_name|
logcfg_source = node['elkstack']['config']['custom_logstash'][logcfg_name]['source']
logcfg_cookbook = node['elkstack']['config']['custom_logstash'][logcfg_name]['cookbook']
logcfg_variables = node['elkstack']['config']['custom_logstash'][logcfg_name]['variables']

# add one more config for our additional logs
logstash_custom_config logcfg_name do
Expand Down
9 changes: 4 additions & 5 deletions recipes/logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@
end

# install additional stacks logstash configuration
node['elkstack']['config']['custom_logstash']['name'].each do |logcfg|
logcfg_name = node['elkstack']['config']['custom_logstash'][logcfg]['name']
logcfg_source = node['elkstack']['config']['custom_logstash'][logcfg]['source']
logcfg_cookbook = node['elkstack']['config']['custom_logstash'][logcfg]['cookbook']
logcfg_variables = node['elkstack']['config']['custom_logstash'][logcfg]['variables']
node['elkstack']['config']['custom_logstash'].keys.each do |logcfg_name|
logcfg_source = node['elkstack']['config']['custom_logstash'][logcfg_name]['source']
logcfg_cookbook = node['elkstack']['config']['custom_logstash'][logcfg_name]['cookbook']
logcfg_variables = node['elkstack']['config']['custom_logstash'][logcfg_name]['variables']

# add one more config for our additional logs
logstash_custom_config logcfg_name do
Expand Down
7 changes: 2 additions & 5 deletions test/fixtures/cookbooks/wrapper/recipes/logstash_override.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Attempt to supply an additional logstash configuration file like a real
# wrapper cookbook would -- see README.md.
node.set_unless['elkstack']['config']['custom_logstash']['name'] = []
node.set['elkstack']['config']['custom_logstash']['name'].push('wrapper')
node.set['elkstack']['config']['custom_logstash']['wrapper']['name'] = 'input_test'
node.set['elkstack']['config']['custom_logstash']['wrapper']['cookbook'] = 'wrapper'
node.set['elkstack']['config']['custom_logstash']['wrapper']['variables'] = { path: '/special_test_path' }
node.set['elkstack']['config']['custom_logstash']['input_test']['cookbook'] = 'wrapper'
node.set['elkstack']['config']['custom_logstash']['input_test']['variables'] = { path: '/special_test_path' }