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

parser: support 'types' feature #310

Merged
merged 1 commit into from
Jul 4, 2017
Merged

Conversation

nokute78
Copy link
Collaborator

to support #308

I added 'types' feature of parser like fluentd.
note: http://docs.fluentd.org/v0.12/articles/parser_regexp#types

We can define data types at parsers.conf.
The syntax is

types <field_name_1>:<type_name_1> <field_name_2>:<type_name_2> ...

Now these type_names are supported.

  • integer
  • float
  • bool

Parsers.conf example

[PARSER]
    Name dummy_test
    Format regex
    Regex ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>[^ ]+)$
    Types INT:integer FLOAT:float BOOL:bool

Configuration File

Try to parse "100 12.1 true strings"

[SERVICE]
    Parsers_File /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/parsers.conf

[INPUT]
    Name dummy
    dummy {"test":"100 12.1 true strings"}


[FILTER]
    Name parser
    Match *
    Key_Name test
    Parser dummy_test

[OUTPUT]
    Name stdout
    Match *

Output example

$ bin/fluent-bit -c dummy2.conf 
Fluent-Bit v0.12.0
Copyright (C) Treasure Data

[2017/06/29 22:48:59] [ info] [engine] started
[0] dummy.0: [1498744140.000618457, {"INT"=>100, "FLOAT"=>12.100000, "BOOL"=>true, "STRING"=>"strings"}]
[1] dummy.0: [1498744141.000545821, {"INT"=>100, "FLOAT"=>12.100000, "BOOL"=>true, "STRING"=>"strings"}]
[2] dummy.0: [1498744142.001582373, {"INT"=>100, "FLOAT"=>12.100000, "BOOL"=>true, "STRING"=>"strings"}]
[3] dummy.0: [1498744143.002502398, {"INT"=>100, "FLOAT"=>12.100000, "BOOL"=>true, "STRING"=>"strings"}]

If no "types" option, the output is like this. All field are string.

$ bin/fluent-bit -c dummy2.conf 
Fluent-Bit v0.12.0
Copyright (C) Treasure Data

[2017/06/29 22:49:50] [ info] [engine] started
[0] dummy.0: [1498744191.001413632, {"INT"=>"100", "FLOAT"=>"12.1", "BOOL"=>"true", "STRING"=>"strings"}]
[1] dummy.0: [1498744192.000833594, {"INT"=>"100", "FLOAT"=>"12.1", "BOOL"=>"true", "STRING"=>"strings"}]
[2] dummy.0: [1498744193.000141314, {"INT"=>"100", "FLOAT"=>"12.1", "BOOL"=>"true", "STRING"=>"strings"}]
[3] dummy.0: [1498744194.000462812, {"INT"=>"100", "FLOAT"=>"12.1", "BOOL"=>"true", "STRING"=>"strings"}]

Signed-off-by: Takahiro YAMASHITA <[email protected]>
@edsiper edsiper merged commit b8d2f2d into fluent:master Jul 4, 2017
@edsiper
Copy link
Member

edsiper commented Jul 4, 2017

thanks!

@isavcic
Copy link

isavcic commented Jun 24, 2020

Where in the world is the documentation for this???

@nokute78 nokute78 deleted the parser_types branch June 26, 2020 23:33
@nokute78
Copy link
Collaborator Author

@isavcic Would you see old docs ?
https://docs.fluentbit.io/manual/v/1.2/parser#configuration-parameters
It seems to be gone recent documentation update...

key description
Types Specify the data type of parsed field. The syntax is types <field_name_1>:<type_name_1> <field_name_2>:<type_name_2> .... The supported types are string(default), integer, bool, float, hex.

rawahars pushed a commit to rawahars/fluent-bit that referenced this pull request Oct 24, 2022
fluent#310)

I added two options to mitigate unstable DNS issues on Windows.

Both will be available on Fluent Bit v1.5.

Signed-off-by: Fujimoto Seiji <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants