module ElasticsearchCommon
Public Class Methods
new()
click to toggle source
Calls superclass method
ElasticsearchQuery::new
# File lib/sensu-plugins-elasticsearch/elasticsearch-common.rb, line 23 def initialize super() end
Public Instance Methods
client()
click to toggle source
# File lib/sensu-plugins-elasticsearch/elasticsearch-common.rb, line 27 def client transport_class = nil if config[:transport] == 'AWS' transport_class = Elasticsearch::Transport::Transport::HTTP::AWS end host = { host: config[:host], port: config[:port], request_timeout: config[:timeout], scheme: config[:scheme] } if !config[:user].nil? && !config[:password].nil? host[:user] = config[:user] host[:password] = config[:password] host[:scheme] = 'https' unless config[:scheme] end transport_options = {} if config[:headers] headers = {} config[:headers].split(',').each do |header| h, v = header.split(':', 2) headers[h.strip] = v.strip end transport_options[:headers] = headers end @client ||= Elasticsearch::Client.new(transport_class: transport_class, hosts: [host], region: config[:region], transport_options: transport_options) end