-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sniff support should set scheme to the same as from the initial provided list of URL's #1569
Comments
Thanks for bringing this up. The process of sniffing is described in the wiki. We're relying on the data returned by Elasticsearch itself. Out of the top of my head, I can't remember how ES internally tells to use http vs. https, but I think it's that the Nodes Info API returns a Blindly using the scheme of the initial request is not the right choice, because the cluster might be configured differently. I have to check if it works correctly in your usage scenario with EDIT: Maybe you can send the output of |
These are docker systems configured using the flags provided in this None of the nodes are available over anything but HTTPS, this is an attempt to reach them over HTTP:
|
After spending some time spelunking through the official Then when it has sniffed the node, it calls: Which has:
Which just replaces the This would mean that Unfortunately I can't find any official documentation for how to implement sniffing, but it seems to me that The initial URL string provided by the user is parsed here: |
A lot has happened in this area, it seems. I've not heard of any problems from other users in at least the last two major versions. But maybe people disable this by default, as is the default in the official drivers as well. Anyway, the official Go driver uses this package as a transport, and uses this algorithm to do node discovery. I will have to review the changes. EDIT: typo. |
Sorry, I reviewed the Python packages as I was more familiar with Python. But the go driver is a lot less complicated! https://github.com/elastic/elastic-transport-go/blob/main/elastictransport/discovery.go#L125 sets the scheme to whatever the scheme is for the first URL provided to that function, which would be HTTPS in our case. |
I will see if I can pick that up for the next release. Thanks for picking this up. |
Which version of Elastic are you using?
[x] elastic.v7 (for Elasticsearch 7.x)
[ ] elastic.v6 (for Elasticsearch 6.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v2 (for Elasticsearch 1.x)
Please describe the expected behavior
telegraf uses Elastic and allows for sniffing, however it does not call
.setScheme
here:https://github.com/influxdata/telegraf/blob/master/plugins/outputs/elasticsearch/elasticsearch.go#L191-L286
However this shouldn't matter because the initial url when we want to sniff is set correctly with a scheme (
https://elastic01.example.com:9200
). The same scheme should be used when getting the results back from sniffing, right now it is set toc.Scheme
here:https://github.com/olivere/elastic/blob/release-branch.v7/client.go#L1006
Which means that it uses whatever is in the config (with a default value of
http
), and then it fails entirely because it can't connect to any of the sniffed nodes because they have the wrong URL (http instead of https). It also seems like the sniffed entries overwrite the provided URL's.NewClient
should probably try to be a little smarter and assume the scheme that it is provided when initially sniffing.Please describe the actual behavior
It fails to connect to the Elastic Search cluster even though the initial URL is perfectly valid and sniffing has returned valid data.
Any steps to reproduce the behavior?
N/A
The text was updated successfully, but these errors were encountered: