Class: LogStash::Filters::OpenSearchClient
- Inherits:
-
Object
- Object
- LogStash::Filters::OpenSearchClient
- Defined in:
- lib/logstash/filters/opensearch/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(logger, hosts, options = {}) ⇒ OpenSearchClient
constructor
A new instance of OpenSearchClient.
- #search(params) ⇒ Object
Constructor Details
#initialize(logger, hosts, options = {}) ⇒ OpenSearchClient
Returns a new instance of OpenSearchClient.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/logstash/filters/opensearch/client.rb', line 11 def initialize(logger, hosts, = {}) ssl = .fetch(:ssl, false) user = .fetch(:user, nil) password = .fetch(:password, nil) api_key = .fetch(:api_key, nil) = {:headers => {}} [:headers].merge!(setup_basic_auth(user, password)) [:headers].merge!(setup_api_key(api_key)) hosts = hosts.map { |host| { host: host, scheme: 'https' } } if ssl # set ca_file even if ssl isn't on, since the host can be an https url = { ssl: true, ca_file: [:ca_file] } if [:ca_file] ||= {} logger.info("New OpenSearch filter client", :hosts => hosts) @client = ::OpenSearch::Client.new(hosts: hosts, transport_options: , :ssl => ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/logstash/filters/opensearch/client.rb', line 9 def client @client end |
Instance Method Details
#search(params) ⇒ Object
30 31 32 |
# File 'lib/logstash/filters/opensearch/client.rb', line 30 def search(params) @client.search(params) end |