opensearch-project / logstash-input-opensearch

Apache License 2.0
10 stars 15 forks source link

[BUG]There is a bug in parsing the host when ssl is set to true #29

Open naveentatikonda opened 2 years ago

naveentatikonda commented 2 years ago

What is the bug? When the "https" protocol is provided in the host url and ssl is enabled. Then, it is throwing the below error

[ERROR][logstash.javapipeline    ][main] Pipeline error {:pipeline_id=>"main", :exception=>#<Manticore::ResolutionFailure: https: nodename nor servname provided, or not known>

It is the parsing the host "https://localhost:9200" as Hosts: [{:host=>"https", :scheme=>"https", :port=>"//localhost"}] https://github.com/opensearch-project/logstash-input-opensearch/blob/main/lib/logstash/inputs/opensearch.rb#L355-L359

The same configuration works fine if we provide the host name without protocol like "localhost:9200"

How can one reproduce the bug?

  1. Clone the repository
  2. Install this plugin onto logstash by following the instructions in DeveloperGuide.
  3. Update the pipeline configuration using the sample configuration shown below
input {
 opensearch {
     hosts => "https://localhost:9200"
     user => "admin"
     password => "admin"
     index => "test"
     ssl => true
     ssl_certificate_verification => false
     query => '{ "query": { "match_all": {}}, "sort": [ "_doc" ] }'
  }
}

output {
stdout {}
}
  1. Run it to get the error shown above.

What is the expected behavior? It should fetch the documents from the index based on the given query.