Connect underlying ES client so ES version is set#11215
Connect underlying ES client so ES version is set#11215ycombinator merged 1 commit intoelastic:masterfrom ycombinator:fix-mon-es-client-version
Conversation
|
Pinging @elastic/stack-monitoring |
|
An alternative solution here would be to extract the version-setting code from the Output Elasticsearch client's The pro of this alternative solution is that each client can pick and choose what additional duties it wants to perform as part of connecting to Elasticsearch. The con is that if the Output Elasticsearch client's |
cachedout
left a comment
There was a problem hiding this comment.
I'm in favor of the approach as it is presently implemented.
|
jenkins, test this |
Currently, if X-Pack Monitoring is setup for a Beat, the Elasticsearch monitoring code in libbeat tries to make a decision based on the Elasticsearch version over here:
beats/libbeat/monitoring/report/elasticsearch/client.go
Line 120 in 821baec
However, it turns out that the Elasticsearch client (
c.es) never initializes its version properly. As a result,c.es.GetVersion().Majorwill always return0(the zero-value for anint).The reason for this is that the Monitoring Elasticsearch client's
Connect()method does not attempt to determine the Elasticsearch cluster's version:beats/libbeat/monitoring/report/elasticsearch/client.go
Lines 48 to 81 in 821baec
However, if you look at the Output Elasticsearch client's
Connect()method, it does attempt to determine the Elasticsearch cluster's version:beats/libbeat/outputs/elasticsearch/client.go
Lines 675 to 696 in 821baec
Additionally, it also calls any configured connection callbacks.
Since the Monitoring Elasticsearch client is based on the Output Elasticsearch client, this PR makes it so that the first thing the Monitoring Elasticsearch client's
Connect()method does is call the underlying Output Elasticsearch client'sConnect()method. That way the base Output Elasticsearch client can perform any generic connection-related duties before the Monitoring Elasticsearch client performs any Monitoring-specific ones.Resolves #11204