Class: LogStash::Outputs::ElasticSearch::TemplateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/elasticsearch/template_manager.rb

Class Method Summary collapse

Class Method Details

.install_template(plugin) ⇒ Object

To be mixed into the elasticsearch plugin base



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/logstash/outputs/elasticsearch/template_manager.rb', line 4

def self.install_template(plugin)
  return unless plugin.manage_template
  if plugin.template.nil?
    plugin.logger.info("Using default mapping template")
  else
    plugin.logger.info("Using mapping template from", :path => plugin.template)
  end


  template = get_template(plugin.template, plugin.maximum_seen_major_version)
  add_ilm_settings_to_template(plugin, template) if plugin.ilm_in_use?
  plugin.logger.info("Attempting to install template", :manage_template => template)
  install(plugin.client, template_name(plugin), template, plugin.template_overwrite)
rescue => e
  plugin.logger.error("Failed to install template.", :message => e.message, :class => e.class.name, :backtrace => e.backtrace)
end