Module: ElasticsearchCommon
- Includes:
- ElasticsearchQuery
- Defined in:
- lib/sensu-plugins-elasticsearch/elasticsearch-common.rb
Instance Method Summary
collapse
#build_request_options, #es_date_math_string, #indices
Instance Method Details
#client ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# 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]
= {}
config[:headers].split(',').each do ||
h, v = .split(':', 2)
[h.strip] = v.strip
end
transport_options[:headers] =
end
@client ||= Elasticsearch::Client.new(transport_class: transport_class, hosts: [host], region: config[:region], transport_options: transport_options)
end
|
#initialize ⇒ Object
23
24
25
|
# File 'lib/sensu-plugins-elasticsearch/elasticsearch-common.rb', line 23
def initialize
super()
end
|