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

test.lua: output table contents #627

Merged
merged 1 commit into from
Jun 14, 2018
Merged

Conversation

nokute78
Copy link
Collaborator

Recently, we changed the format of filter_lua, JSON -> Lua table.
So, we also need to modify cb_print to handle Lua table.

Now, cb_print doesn't output contents of table.

$ bin/fluent-bit -i mem -F lua -p script=../scripts/test.lua -p call=cb_print -m '*' -o stdout
Fluent-Bit v0.14.0
Copyright (C) Treasure Data

[2018/06/11 22:53:12] [ info] [engine] started (pid=20490)
mem.0	1528725193.000884	table: 0x41f16340
mem.0	1528725194.000263	table: 0x41f16398
mem.0	1528725195.000821	table: 0x41f1ccf0

My patch is to output such JSON like format.

$ bin/fluent-bit -i mem -F lua -p script=../scripts/test.lua -p call=cb_print -m '*' -o stdout
Fluent-Bit v0.14.0
Copyright (C) Treasure Data

[2018/06/11 22:48:53] [ info] [engine] started (pid=20207)
mem.0:  [1528724934.002288, {  Mem.free => 625464, Swap.free => 2064380, Swap.used => 0, Mem.used => 3294704, Mem.total => 3920168, Swap.total => 2064380 }]
mem.0:  [1528724935.001287, {  Mem.free => 625464, Swap.free => 2064380, Swap.used => 0, Mem.used => 3294704, Mem.total => 3920168, Swap.total => 2064380 }]
mem.0:  [1528724936.000483, {  Mem.free => 625464, Swap.free => 2064380, Swap.used => 0, Mem.used => 3294704, Mem.total => 3920168, Swap.total => 2064380 }]

Signed-off-by: Takahiro YAMASHITA <[email protected]>
@edsiper
Copy link
Member

edsiper commented Jun 12, 2018

@nokute78 does it work with nested field ? e.g: {"key": {"map1", 123, "map2": [1, 2, 3]}} ?

@nokute78
Copy link
Collaborator Author

@edsiper No. It supports flat table only.

As you know, it needs recursive function to parse nested table.
I thought it was too much for test script.

@edsiper edsiper merged commit 461e772 into fluent:master Jun 14, 2018
@edsiper
Copy link
Member

edsiper commented Jun 14, 2018

thanks

@nokute78 nokute78 deleted the fix_lua_cb_print branch April 13, 2020 04:49
rawahars pushed a commit to rawahars/fluent-bit that referenced this pull request Oct 24, 2022
Copying from the installation pages using the copy line icon, the `$` is copied and makes the copy/paste pointless.

Signed-off-by: Lantrix <[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.

2 participants