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.1.9 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-filter-csharp-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.1.5 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.16-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.15-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.14-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.13-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.12-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-5.6.11-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.3.2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.3.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/logstash-core-5.6.4-java/lib/logstash/modules/elasticsearch_importer.rb