Sha256: ceb4725fa60af7e184c7f8fcd665fbe9ed9b74e927a8b238c9addc8db414e7ba

Contents?: true

Size: 886 Bytes

Versions: 59

Compression:

Stored size: 886 Bytes

Contents

# encoding: utf-8
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

59 entries across 59 versions & 1 rubygems

Version Path
logstash-core-6.8.23-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.22-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.21-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.20-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.19-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.18-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.17-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.16-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.15-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.14-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.13-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.12-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.11-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.10-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.9-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.8-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.7-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.5.2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.5.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.8.6-java lib/logstash/modules/elasticsearch_importer.rb