Created
February 7, 2013 15:29
-
-
Save lucky-sideburn/4731642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#chef-logstash/attributes/kibana.rb | |
#new attributes..an array will contain hash "index" => "haproxy-%Y.%m.%d" , "port" => "80" | |
default['logstash']['kibana']['smart_index_pattern'] = [] | |
#our settings in our cookbook | |
#fao-logstash/attributes/server.rb | |
set['logstash']['kibana']['smart_index_pattern'] = [{ "index" => "haproxy-%Y.%m.%d" , "port" => "80" }, | |
{ "index" => "java-%Y.%m.%d","port" => "81" }] | |
#chef-logstash/recipes/kibana.rb | |
#a loop for insert all indexes | |
node['logstash']['kibana']['smart_index_pattern'].each do |index| | |
template "/etc/init.d/kibana-" + index["index"].split("-")[0] do | |
source "kibana.init.erb" | |
owner 'root' | |
mode 0755 | |
end | |
template "#{node['logstash']['basedir']}/kibana-#{node['logstash']['kibana']['ruby_version']['version']}/KibanaConfig-" + index["index"].split("-")[0] + ".rb" do | |
source "kibana-config.rb.erb" | |
owner 'root' | |
mode 0755 | |
variables( | |
:index_selected => index["index"] , | |
:port => index["port"] | |
) | |
end | |
end | |
#/chef-logstash/templates/default/kibana-config.rb.erb | |
<% if @port == nil %> | |
KibanaPort = <%= @port %> | |
<% else %> | |
KibanaPort = <%= node['logstash']['kibana']['ruby_version']['port'] %> | |
<% end %> | |
Smart_index_pattern = '<%= @index_selected %>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment