Sha256: ff98c42f57f910a36c3d76041714286a36fa8f33933e8f9f9df12b1538131ad1

Contents?: true

Size: 943 Bytes

Versions: 68

Compression:

Stored size: 943 Bytes

Contents

# encoding: utf-8
require "logstash/namespace"
require "logstash/logging"

module LogStash module Modules class ElasticsearchImporter
  include LogStash::Util::Loggable

  def initialize(client)
    @client = client
  end

  def put(resource, overwrite = true)
    path = resource.import_path
    logger.debug("Attempting PUT", :url_path => path, :file_path => resource.content_path)
    if !overwrite && content_exists?(path)
      logger.debug("Found existing Elasticsearch resource.", :resource => path)
      return
    end
    put_overwrite(path, resource.content)
  end

  private

  def put_overwrite(path, content)
    if content_exists?(path)
      response = @client.delete(path)
    end
    # hmmm, versioning?
    @client.put(path, content).status == 201
  end

  def content_exists?(path)
    response = @client.head(path)
    response.status >= 200 && response.status < 300
  end

end end end # class LogStash::Modules::Importer

Version data entries

68 entries across 68 versions & 5 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb