-
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
Refactor: Renaming prospector to input #6078
Conversation
Missed the docker compose commit. . . |
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.
Change looks good to me. The only thing missing from my perspective is some system tests that validate that the old options are still working as expected. As this is a pretty major change without expecting to break BC we should make sure the old options still work as intended and deprecated messages are logged as expected to make sure users knows about it.
@@ -54,6 +54,14 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) { | |||
return nil, err | |||
} | |||
|
|||
if len(config.Prospectors) > 0 { |
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.
Can you add some system tests with the old config options to make sure this works as expected? We have done this for previous renamings and I think it's pretty useful to make sure it actually works and be remembered that we break something, when we remove it.
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.
Of course, I was planning to do it in a dedicated PR, because right now all the tests use the old config options :)
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.
SGTM. Didn't realise it's all on the old config. Good to know.
// event processing | ||
common.EventMetadata `config:",inline"` // Fields and tags to add to events. | ||
Processors processors.PluginConfig `config:"processors"` | ||
|
||
// implicit event fields | ||
Type string `config:"type"` // prospector.type | ||
Type string `config:"type"` // input.type |
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.
In case the comment is correct, this is a breaking change of the data format I think.
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.
Why its a breaking changes? The name of the private struct changed and the only the comment changed?
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.
Only indirectly breaking if the comment is correct. I assume when looking at it that you removed prospector.type
from the event, but you copied it to input.type
.
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.
I did not remove the prospector.type
in the event. https://github.com/elastic/beats/pull/6078/files#diff-b6244e3a701e1fad9969756499d1e8fcR99
filebeat/channel/factory.go
Outdated
@@ -99,6 +99,9 @@ func (f *OutletFactory) Create(cfg *common.Config, dynFields *common.MapStrPoint | |||
fields["prospector"] = common.MapStr{ | |||
"type": config.Type, | |||
} | |||
fields["input"] = common.MapStr{ |
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.
Could we call this event.type
instead if we already duplicate the field? Thinking of ECS here.
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.
I can change it to event.type
, I would prefer to not mix concerns of ECS, but since we already add this fields it should be OK.
@@ -82,7 +83,15 @@ func mergeConfigFiles(configFiles []string, config *Config) error { | |||
return fmt.Errorf("Failed to read %s: %s", file, err) | |||
} | |||
|
|||
config.Prospectors = append(config.Prospectors, tmpConfig.Filebeat.Prospectors...) | |||
if len(tmpConfig.Filebeat.Prospectors) > 0 { |
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.
Some system tests for this would also be nice.
filebeat/config/config.go
Outdated
if len(tmpConfig.Filebeat.Inputs) > 0 { | ||
return fmt.Errorf("prospectors and inputs used in the configuration file, define only inputs not both") | ||
} | ||
config.Inputs = append(config.Inputs, tmpConfig.Filebeat.Prospectors...) |
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.
Nit but code wise I would prefer if you would do here what you did above which is copying tmpConfig.Filebeat.Prospectors
to tmpConfig.Filebeat.Inputs
and then not do an else. Like this when the code is removed later, nothing changes in the "correct" code.
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.
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.
I have the same logic there https://github.com/elastic/beats/pull/6078/files/c2b149f7d67b082b20f8201db719ba1c01755683#diff-7a00b9fb331934c8b3bb7cf5eac57576R37, So I will remove both.
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.
nevermind, my previous comments, I understand your proposal.
filebeat/docker-compose.yml
Outdated
@@ -28,13 +28,13 @@ services: | |||
|
|||
elasticsearch: | |||
extends: | |||
file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml | |||
file: ../testing/environments/${TESTING_ENVIRONMENT}.yml |
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.
What is the reason you changed this back?
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.
I shouldn't have changed this.
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.
bad rebase on my side.
return nil, fmt.Errorf("error unpacking configuration") | ||
} | ||
|
||
if len(fcfg.Prospector) > 0 { |
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.
Tests ...
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.
I have added unit test for this path, which are a lot simplier than integration test.
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.
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.
The part which I think unit tests here can't cover is to check if it's logged correctly. +1 on the unit test.
@@ -0,0 +1,150 @@ | |||
package input |
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.
I assume that code is mostly copy/paste/rename
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.
Exact, this should be as is.
filebeat/prospector/prospector.go
Outdated
Once: false, | ||
beatDone: beatDone, | ||
} | ||
//+build go1.9 |
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.
Do you really want to add this build flag as we already require Golang 1.9 for beats. Not having it would make us detect if by accident something is built previous to 1.9 and have an error.
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.
We do require golang 1.9, but after looking at it I am not sure we enforce it the correct way.
go version
go version go1.8.3 darwin/amd64
This is with the pragma build go1.9
make
go build -i -ldflags "-X github.com/elastic/beats/libbeat/version.buildTime=2018-01-16T14:18:24Z -X github.com/elastic/beats/libbeat/version.commit=c2b149f7d67b082b20f8201db719ba1c01755683"
fileset/factory.go:7:2: no buildable Go source files in /Users/ph/go/src/github.com/elastic/beats/filebeat/prospector
make: *** [filebeat] Error 1
This is without the pragma build go1.9
go build -i -ldflags "-X github.com/elastic/beats/libbeat/version.buildTime=2018-01-16T14:18:42Z -X github.com/elastic/beats/libbeat/version.commit=c2b149f7d67b082b20f8201db719ba1c01755683"
# github.com/elastic/beats/libbeat/logp
../libbeat/logp/logger.go:8: syntax error: unexpected = in type declaration
make: *** [filebeat] Error 2
@ruflin I have updated and fixed a few of your concerns. Also I didn't update the json expected file, they will come in specific PR for each of the prospector. (re: this concern the event.type) |
@ruflin minus the rebase, anything else you need on this PR? |
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.
LGTM. I added the label in progress
to make sure it does not get merged before we do the next bulk backport to 6.x.
Can you add a CHANGELOG entry and squash the commits?
return nil, fmt.Errorf("error unpacking configuration") | ||
} | ||
|
||
if len(fcfg.Prospector) > 0 { |
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.
The part which I think unit tests here can't cover is to check if it's logged correctly. +1 on the unit test.
} | ||
// GetFactory wrapper for backward compatibility | ||
// Deprecated: See input.GetFactory | ||
var GetFactory = input.GetFactory |
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.
Good timing that Golang 1.9 added this :-)
@@ -213,7 +213,3 @@ path: | |||
data: {{path_data}} | |||
{% endif %} | |||
|
|||
{% if keystore_path %} |
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.
Was this a duplicate?
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
5e66928
to
d027f45
Compare
@ruflin Rebased and changelog added. |
@ph There seem to be some issues on CI (I looked up the commit id). |
This refactor rename the prospector type to the input type, this allow this project to be more aligned with Logstash naming convention and also remove some of the last naming legacy of the `logstash fowarder`. The input name is also more appropriate for the UDP and the Redis code. The prospectors are now moved to the `input` folder. Backward compatibility is keep by using type aliasing over the older `prospector` types. Logs statements were also changed to reflect this refactor. Currently all the code and YAML are still using the *prospector(s)* keys, but other PRs will move the usage to the inputs. If the `input(s)` are present we will use them instead of the *prospectors* key.
d027f45
to
0e31dc7
Compare
@ruflin I have fixed the keystore issue, added the |
Small PR for @ph, big step for Filebeat 🎉 |
This commit revert the decision done in elastic#6078 and will use `input.type` to replace the `prospector.type`
This commit revert the decision done in #6078 and will use `input.type` to replace the `prospector.type`
This got renamed in Beats 6.3: elastic/beats#6078
* Rename beat prospectors to inputs This got renamed in Beats 6.3: elastic/beats#6078 * Add graylog fields to beats default templates The collector "Show messages" button links to a search for a matching `gl2_source_collector`. Thus we need to define these fields in every beats configuration. Furthermore, we need to set `fields_under_root` because the new Beats input does not strip away the "fields_" prefix for us. Only "Beats Legacy" does that. * Add filebeat and winlogbeat default template Provide users with a sensible default template to get them started. * Fix template variable name It's called sidecarVersion now.
This is the first PR to refactor the usage of the
prospector
type to theinput
type, the code uses type aliasing to allow the input and the prospector to continue to work in parallel, providing an easier update path to the community beats. We have build pragma option to make sure we cannot compile this project if you are using an older version of go.The prospector code didn't change in this PR, they were just moved into the input directory and still use the old prospector type.
Changes that will come after:
Note: for clarity I didn't merge the commits in this PR before the review.
This is a followup of #5944