Sha256: c003c330355ec0ff52d17d99ecc97e085108c654c20718babecab0734d31f697
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
# encoding: utf-8 require "elasticsearch" require "base64" module LogStash module Filters class ElasticsearchClient attr_reader :client def initialize(user, password, options={}) ssl = options.fetch(:ssh, false) hosts = options[:hosts] @logger = options[:logger] transport_options = {} if user && password token = ::Base64.strict_encode64("#{user}:#{password.value}") transport_options[:headers] = { Authorization: "Basic #{token}" } end host.map! {|h| { host: h, scheme: 'https' } } if ssl transport_options[:ssl] = { ca_file: options[:ca_file] } if ssl && options[:ca_file] @logger.info("New ElasticSearch filter", :hosts => hosts) @client = ::Elasticsearch::Client.new(index: options[:index], hosts: hosts, transport_options: transport_options) end def search(params) @client.search(params) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logstash-filter-elasticsearch-3.0.0 | lib/logstash/filters/elasticsearch/client.rb |
logstash-filter-elasticsearch-2.1.0 | lib/logstash/filters/elasticsearch/client.rb |