Goal
Parsers are the successors of readers of the log input. They provide a more flexible message parsing. At the moment they are only available in the filestream input. But the functionality could be useful in other inputs.
We have to inspect all available inputs in Filebeat to see if it makes sense to add parsers. If the answer is yes, then the feature should be added.
Parsers
How to add parsers to an input
1. Add parsers code to the input
The parser.Config object has its own Unpack function, so it is enough for you to add it as an attribute to your configuration.
type myInputConfiguration struct {
// other attributes
parsers parser.Config `config:",inline"`
}
Then create the parser based on the configuration. The Create function expects a reader.Reader as a parameter it can read from.
var reader reader.Reader
p = inp.config.parsers.Create(reader)
Example configuration accepted by the code above
parsers:
- multiline:
type: count
lines_count: 3
2. Add parsers to the reference configuration
Add the reference configuration to either
filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl
x-pack/filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl
3. Add parsers to the documentation of the input
There is no common parsers section at the moment because it might not make sense to document all parsers for every input.
Goal
Parsers are the successors of readers of the
loginput. They provide a more flexible message parsing. At the moment they are only available in thefilestreaminput. But the functionality could be useful in other inputs.We have to inspect all available inputs in Filebeat to see if it makes sense to add
parsers. If the answer is yes, then the feature should be added.Parsers
How to add parsers to an input
1. Add parsers code to the input
The
parser.Configobject has its ownUnpackfunction, so it is enough for you to add it as an attribute to your configuration.Then create the parser based on the configuration. The
Createfunction expects areader.Readeras a parameter it can read from.Example configuration accepted by the code above
2. Add
parsersto the reference configurationAdd the reference configuration to either
filebeat/_meta/config/filebeat.inputs.reference.yml.tmplx-pack/filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl3. Add
parsersto the documentation of the inputThere is no common parsers section at the moment because it might not make sense to document all parsers for every input.