Sha256: 6003aac64ab8f059e2047b6afcaecd1b228deb9bd9109c88ee2a0f891270b454

Contents?: true

Size: 1.04 KB

Versions: 43

Compression:

Stored size: 1.04 KB

Contents

module Fluent::ElasticsearchIndexTemplate

  def get_template(template_file)
    if !File.exists?(template_file)
      raise "If you specify a template_name you must specify a valid template file (checked '#{template_file}')!"
    end
    file_contents = IO.read(template_file).gsub(/\n/,'')
    JSON.parse(file_contents)
  end

  def template_exists?(name)
    client.indices.get_template(:name => name)
    return true
  rescue Elasticsearch::Transport::Transport::Errors::NotFound
    return false
  end

  def template_put(name, template)
    client.indices.put_template(:name => name, :body => template)
  end

  def template_install(name, template_file)
    if !template_exists?(name)
      template_put(name, get_template(template_file))
      log.info("Template configured, but no template installed. Installed '#{name}' from #{template_file}.")
    else
      log.info("Template configured and already installed.")
    end
  end

  def templates_hash_install (templates)
    templates.each do |key, value|
      template_install(key, value)
    end
  end

end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
fluent-plugin-elasticsearch-2.2.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.12.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.12.0.rc.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.2.0.rc.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.11.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.1.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.11.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.1.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.10.3 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.10.3.rc.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.1.rc.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.10.2 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.0.rc.7 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.10.1 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.0.rc.6 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.10.0 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-2.0.0.rc.5 lib/fluent/plugin/elasticsearch_index_template.rb
fluent-plugin-elasticsearch-1.9.7 lib/fluent/plugin/elasticsearch_index_template.rb