Bump ruby/setup-ruby from 1.298.0 to 1.299.0 (#114)
Bumps ruby/setup-ruby from 1.298.0 to 1.299.0.
Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
Grok Parser for Fluentd
This is a Fluentd plugin to enable Logstash’s Grok-like parsing logic.
Requirements
What’s Grok?
Grok is a macro to simplify and reuse regexes, originally developed by Jordan Sissel.
This is a partial implementation of Grok’s grammer that should meet most of the needs.
How It Works
You can use it wherever you used the
formatparameter to parse texts. In the following example, it extracts the first IP address that matches in the log.If you want to try multiple grok patterns and use the first matched one, you can use the following syntax:
Multiline support
You can parse multiple line text.
You can use multiple grok patterns to parse your data.
Fluentd accumulates data in the buffer forever to parse complete data when no pattern matches.
You can use this parser without
multiline_start_regexpwhen you know your data structure perfectly.Configurations
See also: Config: Parse Section - Fluentd
time_format (string) (optional): The format of the time field.
grok_pattern (string) (optional): The pattern of grok. You cannot specify multiple grok pattern with this.
custom_pattern_path (string) (optional): Path to the file that includes custom grok patterns
grok_failure_key (string) (optional): The key has grok failure reason.
grok_name_key (string) (optional): The key name to store grok section’s name
multi_line_start_regexp (string) (optional): The regexp to match beginning of multiline. This is only for “multiline_grok”.
grok_pattern_series (enum) (optional): Specify grok pattern series set.
legacy.<grok> section (optional) (multiple)
time.Examples
Using grok_failure_key
This generates following events:
Using grok_name_key
This will add keys like following:
grok_name: "apache_log"if the record matchesHTTPD_COMBINEDLOGgrok_name: "ip_address"if the record matchesIPgrok_name: "rest_message"if the record matchesGREEDYDATAAdd
grokfailurekey to the record if the record does not match any grok pattern. See also test code for more details.How to parse time value using specific timezone
This will parse the
timevalue as “Asia/Tokyo” timezone.See Config: Parse Section - Fluentd for more details about timezone.
How to write Grok patterns
Grok patterns look like
%{PATTERN_NAME:name}where “:name” is optional. If “name” is provided, then it becomes a named capture. So, for example, if you have the grok patternit matches
but only extracts “foo.example” as {“host”: “foo.example”}
Please see
patterns/*for the patterns that are supported out of the box.How to add your own Grok pattern
You can add your own Grok patterns by creating your own Grok file and telling the plugin to read it. This is what the
custom_pattern_pathparameter is for.custom_pattern_pathcan be either a directory or file. If it’s a directory, it reads all the files in it.FAQs
1. How can I convert types of the matched patterns like Logstash’s Grok?
Although every parsed field has type
stringby default, you can specify other types. This is useful when filtering particular fields numerically or storing data with sensible type information.The syntax is
e.g.,
Unspecified fields are parsed at the default string type.
The list of supported types are shown below:
stringboolinteger(“int” would NOT work!)floattimearrayFor the
timeandarraytypes, there is an optional 4th field after the type name. For the “time” type, you can specify a time format like you would intime_format.For the “array” type, the third field specifies the delimiter (the default is “,”). For example, if a field called “item_ids” contains the value “3,4,5”,
types item_ids:arrayparses it as [“3”, “4”, “5”]. Alternatively, if the value is “Adam|Alice|Bob”,types item_ids:array:|parses it as [“Adam”, “Alice”, “Bob”].Here is a sample config using the Grok parser with
in_tailand thetypesparameter:Notice
If you want to use this plugin with Fluentd v0.12.x or earlier, you can use this plugin version v1.x.
See also: Plugin Management | Fluentd
License
Apache 2.0 License