-
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
Ingest Pipeline tester using Simulate API #6261
Conversation
633aa23
to
4effa77
Compare
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.
This is really cool as it should make testing a pipeline much easier. Having this code in Golang means it could probably also replace parts of our slow "system module tests".
For the naming of the variables / options I suggest to keep them identical to what we have in filebeat. So for multiline it is for example -multiline.match
.
filebeat/scripts/tester/main.go
Outdated
func getMultiline(s *bufio.Scanner, line string, multiNegate bool, regex *regexp.Regexp) []string { | ||
matches := regex.MatchString(line) | ||
fullLine := line | ||
if matches || !matches && multiNegate { |
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 reuse here the logic of our multiline reader to make sure we have the exact same behaviour?
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.
Done.
💯 The difference between this and #5028 is, I wanted to run tests based on a user module/prospector configuration. Right from config file. This PR requires you to name the pipeline.json file under test. Both have slightly different use-cases, user vs. module developer. Still this command can still be used by users for very custom pipeline configurations. A mix of both would be nice. E.g.:
As one can push multiple events via SimulateAPI at once, it might be somewhat daunting to read/interpret the output. It's too easy to miss an error. Plus, for debugging purposes it's helpful to add the verbose flag to the API call (in order get collect per processor input/output). E.g. how about: - only show errored events by default (only failed documents, not all)
|
filebeat/scripts/tester/main.go
Outdated
r = reader.NewStripNewline(r) | ||
|
||
if multiPattern != "" { | ||
p := match.MustCompile(multiPattern) |
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.
this panics on invalid pattern. Let's create a somewhat user-friendly error message.
filebeat/scripts/tester/main.go
Outdated
return nil, err | ||
} | ||
} | ||
r = reader.NewLimit(r, 10485760) |
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 limit should be configurable. Think, users with very big xml documents :/
651c301
to
ece6d39
Compare
filebeat/scripts/tester/main.go
Outdated
} | ||
} | ||
} | ||
func getLogsFromFile(logfile, multiPattern string, multiNegate bool, matchMode string, maxBytes int) ([]string, 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.
Kinda scary considering users potentially using a 1GB test file :)
filebeat/scripts/tester/main.go
Outdated
} | ||
defer f.Close() | ||
|
||
encFactory, ok := encoding.FindEncoding("utf8") |
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.
encoding should be configurable. Especially windows users will oftentimes have utf16
4f8464f
to
c12449e
Compare
@urso I addressed your review notes. |
filebeat/scripts/tester/main.go
Outdated
|
||
encFactory, ok := encoding.FindEncoding(conf.encoding) | ||
if !ok { | ||
return nil, fmt.Errorf("unable to find 'utf8' encoding") |
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.
error message should not say utf8
3343785
to
79ddb1a
Compare
This script is tests a single log line or multiple lines against an Ingest pipeline using the Simulate API. It creates a request and displays the response from Elasticsearch.
Usage
Finding pipelines
Examples
Correct pipeline
Input pipeline: PostgreSQL/log
Input log:
2017-04-03 22:32:14.322 CEST [31225] postgres@mydb LOG: could not receive data from client: Connection reset by peer
Incorrect pipeline
Input pipeline: PostgreSQL/log
Input log:
2017-04-03 22:32:14.322 [31225] postgres@mydb LOG: could not receive data from cl ient: Connection reset by peer
TODO
Questions