class LogStash::Outputs::ElasticSearch::TemplateManager
Public Class Methods
install_template(plugin)
click to toggle source
To be mixed into the elasticsearch plugin base
# File lib/logstash/outputs/elasticsearch/template_manager.rb, line 4 def self.install_template(plugin) return unless plugin.manage_template plugin.logger.info("Using mapping template from", :path => plugin.template) template = get_template(plugin.template) plugin.logger.info("Attempting to install template", :manage_template => template) install(plugin.client, plugin.template_name, template, plugin.template_overwrite) rescue => e plugin.logger.error("Failed to install template.", :message => e.message, :class => e.class.name) end
Private Class Methods
default_template_path()
click to toggle source
# File lib/logstash/outputs/elasticsearch/template_manager.rb, line 25 def self.default_template_path ::File.expand_path('elasticsearch-template.json', ::File.dirname(__FILE__)) end
get_template(path)
click to toggle source
# File lib/logstash/outputs/elasticsearch/template_manager.rb, line 16 def self.get_template(path) template_path = path || default_template_path read_template_file(template_path) end
install(client, template_name, template, template_overwrite)
click to toggle source
# File lib/logstash/outputs/elasticsearch/template_manager.rb, line 21 def self.install(client, template_name, template, template_overwrite) client.template_install(template_name, template, template_overwrite) end
read_template_file(template_path)
click to toggle source
# File lib/logstash/outputs/elasticsearch/template_manager.rb, line 29 def self.read_template_file(template_path) raise ArgumentError, "Template file '#{@template_path}' could not be found!" unless ::File.exists?(template_path) template_data = ::IO.read(template_path) LogStash::Json.load(template_data) end