Skip to content
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

Refactor filebeat connector #12997

Merged
merged 8 commits into from
Jul 26, 2019
Merged

Conversation

urso
Copy link

@urso urso commented Jul 20, 2019

Requires: #12996

Refactor filebeat/channel package

The filebeat channel package wraps the publisher pipeline,
providing support for preparing custom user settings. The drawback is,
that inputs can not configure custom fields, processors, and ACK
handlers. The later is required for implementing end-to-end ACK.

This refactoring modifies the channel.Factory and channel.Connector
types, such that input authors are able to make use of all the
capabilities of the publisher pipeline.

Inputs are free to configure the PublishMode. If not set, then filebeat
defaults to guaranteed sends.

The channel.Outleter should become more similar to beat.Client in the
future, and will be eventually removed. A side effect of moving closer
to beat.Client is the removal of the filebeat/util package.
The complex shutdown handling in filebeat still prevents us from
removing channel.Outlet. The complex shutdown handling is still required
for handling the interactions between the logs input and the registrar
on shutdown.

@urso urso added the in progress Pull request is currently in progress. label Jul 20, 2019
@urso urso requested a review from ph July 20, 2019 23:42
@urso urso force-pushed the refactor-filebeat-connector branch from 259470a to f1c5eb4 Compare July 22, 2019 19:31
@urso urso force-pushed the refactor-filebeat-connector branch from 84a9af8 to 4af826c Compare July 22, 2019 22:08
@urso urso marked this pull request as ready for review July 22, 2019 22:16
@urso urso requested a review from a team as a code owner July 22, 2019 22:16
@urso urso added Filebeat Filebeat review and removed in progress Pull request is currently in progress. labels Jul 22, 2019
@urso
Copy link
Author

urso commented Jul 23, 2019

Jenkins, test this.

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work as always @urso, I like that we remove the util.Data It always look a bit weird before, I think its a safe refactoring with the number of tests we have.

setOptional(meta, "pipeline", config.Pipeline)
setOptional(fields, "fileset.name", config.Fileset)
setOptional(fields, "service.type", serviceType)
setOptional(fields, "input.type", config.Type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: What if we centralize this operation in a single method?

meta, fields, err := withOptional(clients.Processing) 

Note that the err is not mandatory but could be used if values should not be changed or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth it to have a central method that change the default values of the meta or fields in an event. I am just trying to put myself in the following mind: Where would I look for default added fields or meta?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this, but not only for fields and meta. This function basically merges some default ClientConfig with the one provided by the input. So I was wondering how generic this merge should be. But yet the order might be somewhat filebeat specific, so I decided to postpone it if there is need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am OK to postpone it, it might be premature to extract it.

mode := clientCfg.PublishMode
if mode == beat.DefaultGuarantees {
mode = beat.GuaranteedSend
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth to log it in debug? it would be explicit but might scare people. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't log it here. If we log it, then we should also log the input type and maybe some config id. This information is lost here. So far GuaranteedSend is the default for everyone and no input allows users to change this.
If an input supports multiple modes in the future, then it should log the mode being used.

filebeat/input/log/harvester.go Outdated Show resolved Hide resolved
urso added 7 commits July 26, 2019 00:06
The filebeat channel package wraps the publisher pipeline,
providing support for preparing custom user settings. The drawback is,
that inputs can not configure custom fields, processors, and ACK
handlers. The later is required for implementing end-to-end ACK.

This refactoring modifies the channel.Factory and channel.Connector
types, such that input authors are able to make use of all the
capabilities of the publisher pipeline.

Inputs are free to configure the PublishMode. If not set, then filebeat
defaults to guaranteed sends.

The channel.Outleter should become more similar to beat.Client in the
future, and will be eventually removed. A side effect of moving closer
to beat.Client is the removal of the filebeat/util package.
The complex shutdown handling in filebeat still prevents us from
removing channel.Outlet. The complex shutdown handling is still required
for handling the interactions between the logs input and the registrar
on shutdown.
@urso urso force-pushed the refactor-filebeat-connector branch from 0966542 to 1a908e8 Compare July 25, 2019 22:48
@urso urso merged commit c8128cb into elastic:master Jul 26, 2019
@urso urso deleted the refactor-filebeat-connector branch July 26, 2019 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants