Class: LogStash::Outputs::OpenSearch::TemplateManager

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

Class Method Summary collapse

Class Method Details

.install_template(plugin) ⇒ Object

To be mixed into the opensearch plugin base



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/logstash/outputs/opensearch/template_manager.rb', line 13

def self.install_template(plugin)
  return unless plugin.manage_template
  if plugin.template
    plugin.logger.info("Using mapping template from", :path => plugin.template)
    template = read_template_file(plugin.template)
  else
    plugin.logger.info("Using a default mapping template", :version => plugin.maximum_seen_major_version,
                                                           :ecs_compatibility => plugin.ecs_compatibility)
    template = load_default_template(plugin.maximum_seen_major_version, plugin.ecs_compatibility, plugin.client.legacy_template?)
  end

  plugin.logger.debug("Attempting to install template", template: template)
  install(plugin.client, template_name(plugin), template, plugin.template_overwrite)
end