-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Separate ES client code from ES output code #16150
Conversation
e4b7035
to
4091e0d
Compare
4996f9f
to
5470131
Compare
CompressionLevel int `config:"compression_level" validate:"min=0, max=9"` | ||
EscapeHTML bool `config:"escape_html"` | ||
Timeout time.Duration `config:"timeout"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe as follow up, but these settings look quite generic, but HTTP focused. Just wondering if it would make sense to have these in libbeat/common/transport in one way or the other. We've got a many HTTP clients, with different set of settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that makes sense to me. I'd prefer to do it as a follow up PR in which we look at HTTP settings across the various clients and consolidate the common ones somewhere under libbeat/common/transport
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #16856 to track this refactoring as a follow up.
libbeat/esleg/eslegclient/config.go
Outdated
EscapeHTML: false, | ||
TLS: nil, | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config can store pointers and map[string]interface{}
. I'd sleep a little better if we'd turn these template configurations into functions:
func defaultConfig() config {
...
}
This guarantees that we can never share pointers/references by accident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 63664e5.
87e3512
to
a61779d
Compare
CI failures are unrelated (same failures are also see in latest |
Is this going to be backported to |
@urso WDYT about @simitt's question above? It would be very hard to backport this PR into OTOH, we will need these changes in |
Just for clarification - I did not mean to suggest backporting, just wanted to know as I am in the process of creating missing backports for APM Server. |
* Separate ES client code from ES output code (#16150) * Basic extraction of ES client code from ES output code * Move test * Removing duplicate function in monitoring reporter * Break import cycle * Guard onConnect callback execution * Replace use of field with getter * Moving common bulk API response processing into esclientleg * Moving API integration tests * Fixing references in tests * Adding developer CHANGELOG entry * Move LoadJSON method * Move callbacks to own file * Move client-related constructors into client.go file * Reducing global logging usage * Use new constructor in test * Passing logger in test * Use logger in test * Use struct fieldnames when initializing * Use constructor in test * Fixing typos * Replace esclient.ParseProxyURL with generic function in common * Imports formatting * Moving more fields from ES output client to esclientleg.Connection * Moving more fields * Update test code * Use new TLS package * Extracting common test code into eslegtest package * Replace uses of elasticsearch output client with esclientleg.NewConnection * Replacing uses of ES output client struct with esclientleg.Connection * Handle callbacks * Fixing formatting * Fixing import cycle * Fixing import and package name * Fixing imports * More fixes * Breaking import cycle * Removing unused function * Adding back missing statement * Fixing param * Fixing package name * Include ES output plugin so it's registered * Proxy handling * Let Connection handle ProxyDisable setting * Only parse proxy field from config if set * Cast timeout ints * Parse proxy URL * Fixing proxy integration test * Fixing ILM test * Updating expected request count in test * Fixing package names * Lots more refactoring!!! * Move timeout field * More fixes * Adding missing files * No need to pass HTTP any more * Simplifying Bulk API usage * Removing unused code * Remove bulk state from Connection * Removing empty file * Moving Bulk API response streaming parsing code back into ES output package * Don't make monitoring bulk parsing code use streaming parser * Replacing old HTTP struct passing * Removing HTTP use * Adding build tag * Fixing up tests * Allow default scheme to be configurable * Adding versions to import paths * Remove redundant check * Undoing unnecessary heartbeat import change * Forgot to resolve conflicts * Fixing imports * Running go mod tidy * Revert "Remove redundant check" This reverts commit c5fde6ff3be765a89c0bc20f9cae8f697d08d47e. * Fixing args order * Removing extraneous parameter * Removing wrong errors package import * Fixing order of arguments * Fixing package name * Instantiating logger for tests * Making streaming JSON parser private to ES output package * Detect and try to fix scheme before parsing URL * Making Connection private to ES output Client * Update test * Replace client.Ping() calls with client.Connect() calls in test code * Updating tests * Removing usage of ES output from monitoring code! * Using strings.Index instead of strings.SplitN * Return default config via function call * Removing "escape hatch" method to expose underlying connection from ES output client * Using client connection in tests * Re-implement Test() method for ES output client * Adding back missing import / sorting imports * Removing unused import * Fixing up developer CHANGELOG * Clean up rebase * Rebase cleanup * Making 7.x specific adaptations (ML setup in Filebeat) * Updating go.mod and go.sum files * Running go mod tidy
What does this PR do?
This PR introduces a new package,
libbeat/esleg/eslegclient
. This package contains code pertaining to an Elasticsearch HTTP API client implementation that was previously part of thelibbeat/outputs/elasticsearch
package.This PR is just the first step towards eventually introducing the official Elasticsearch HTTP API client,
go-elasticsearch
, into the Beats codebase. To that end, the new package introduced in this PR is namedeslegclient
, to stand for legacy Elasticsearch client.Why is it important?
libbeat/outputs/elasticsearch
package to focus primarily on publishing events to Elasticsearch, andgo-elasticsearch
into the Beats codebase.Developer Docs
The
elasticsearch
package below refers tolibbeat/outputs/elasticsearch
. Theeslegclient
package below refers tolibbeat/esleg/eslegclient
.The phrase "replaced by" implies that the new symbol isn't a like-for-like drop-in substitute for the old one. Please look at the new symbol's definition to understand how to use it in place of the old one.
The phrase "moved to" implies a simple relocation of the symbol. The new symbol can be used as a like-for-like drop-in substitute for the old one; just the package suffix will need to be changed.
elasticsearch.Client
is significantly pared down in terms of fields and methods. It only contains fields and methods needed for publishing events using the Elasticsearch output. All other fields and methods have been moved intoeslegclient.Connection
.elasticsearch.Connection
is replaced byeslegClient.Connection
.elasticsearch.NewConnectedClient
is replaced byeslegclient.NewConnectedClient
.elasticsearch.NewElasticsearchClients
is replaced byeslegclient.NewClients
.elasticsearch.MetaBuilder
has been removed.elasticsearch.BulkResult
has moved toeslegclient.BulkResult
elasticsearch.BulkReadToItems
has been unexported.elasticsearch.BulkReadItemStatus
has been unexported.elasticsearch.JSONReader
has been unexported.elasticsearch.NewJSONReader
has been unexported.elasticsearch.ErrNotConnected
has moved toeslegclient.ErrNotConnected
.elasticsearch.ErrJSONEncodeFailed
has moved toeslegclient.ErrJSONEncodeFailed
.elasticsearch.ErrResponseRead
has moved toeslegclient.ErrResponseRead
.elasticsearch.QueryResult
has moved toeslegclient.QueryResult
.elasticsearch.SearchResults
has moved toeslegclient.SearchResults
.elasticsearch.Hits
has moved toeslegclient.Hits
.elasticsearch.CountResults
has moved toeslegclient.CountResults
.elasticsearch.Total
has moved toeslegclient.Total
.Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature worksSince this is a refactoring, existing tests must continue to pass.Related issues