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

Create tool that load dumped event #1165

Merged
merged 16 commits into from
Sep 7, 2016

Conversation

ganmacs
Copy link
Member

@ganmacs ganmacs commented Aug 17, 2016

fluent-binlog-reader is a command line tool to read the data which is saved as Message Pack format.

Usage of fluent-binlog-reader's Commands

head

head is used to display the beginning of a text file.

$ fluent-binlog-reader head packed.log
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}

You can specify the number of events to display.

$ fluent-binlog-reader head -n 1 packed.log
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}

cat

cat reads files sequentially, writing them to standard output.

$ fluent-binlog-reader cat packed.log
2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}

...

2016-08-12T17:24:18+09:00       packed.log      {"message":"dummy"}

formats

formats displays plugins that you can use.

$ fluent-binlog-reader formats
out_file
stdout
json
hash
msgpack
ltsv
csv
single_value

Global Options

--format

You can specify the formatter as shown below.

$ fluent-binlog-reader cat packed.log --format=json
{"message":"dummy"}
...
{"message":"dummy"}

Format params

formatter has configurable params.(e.g. CsvFormatter has delimiter, force_quotes, and fields)
You can pass these params by using -e option.

$ fluent-binlog-reader cat --formats=csv  -e fields=message packed.log
"dummy"
...
"dummy"

--plugin

You can add new plugins path.

# $ touch my_plugins/fomatter_csv2.rb
# $ vi my_plugins/fomatter_csv2.rb

$ fluent-binlog-reader cat formats=csv2 --plugin=my_plugins
...

TODO

  • Subcommands
    • head
    • cat
    • formats
  • adding plugins path
  • specifed format
  • specifed format params
  • add tests

@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch 4 times, most recently from 3191c5d to 1386be4 Compare August 17, 2016 10:10
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from 1386be4 to 7beaa50 Compare August 17, 2016 10:12
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from c406518 to dcd4408 Compare August 18, 2016 06:46
@ganmacs ganmacs changed the title [WIP] Create tool that load dumped event Create tool that load dumped event Aug 18, 2016
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from dcd4408 to 82d394d Compare August 18, 2016 07:43
@tagomoris tagomoris self-assigned this Aug 18, 2016
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch 2 times, most recently from 58b07c7 to 87cbed2 Compare August 19, 2016 05:16
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from 87cbed2 to 64f0cad Compare August 26, 2016 05:28
Commands of fluent-unpacker:
cat : Read files sequentially, writing them to standard output.
haed : Display the beginning of a text file.
foramts : Display plugins that you can use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from 182495e to e186971 Compare August 30, 2016 10:24
@ganmacs
Copy link
Member Author

ganmacs commented Aug 31, 2016

head and cat can share code

Done.

count: -1
}

def initialize(argv = ARGV)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonsense def (just doing super).

@tagomoris
Copy link
Member

I added some minor comments.
The last major problem is naming...
@repeatedly do you have any idea about naming?

Add ensure to re-assignment of timezone.
Remove unnecessary code.
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from 2971639 to 9eda447 Compare September 1, 2016 01:23
@repeatedly
Copy link
Member

repeatedly commented Sep 1, 2016

Hmm... if this tool focuses on binary format, fluent-binlog-reader is good for me.
dumped seems too general because other text files, e.g. result of out_file, are also dumped.

@tagomoris
Copy link
Member

looks good > fluent-binlog-reader

@ganmacs
Copy link
Member Author

ganmacs commented Sep 2, 2016

@tagomoris
I changed a command name unpacker -> binlog-reader

@repeatedly Thank you for your help!

@repeatedly
Copy link
Member

Two directories for test formatter plugins are needed?
test/scripts/fluent/plugin/formatter/{formatter_test1,formatter_test2}.rb seems enough.


if !@options[:plugin].empty? && (dir = @options[:plugin].find { |d| !Dir.exist?(d) })
usage "Directory #{dir} doesn't exist"
elsif !@options[:plugin].empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems verbose.

if !@options[:plugin].empty?
  if dir = @options[:plugin].find { |d| !Dir.exist?(d) }
     usage "Directory #{dir} doesn't exist"
  else
    @options[:plugin].each do |d|
      Fluent::Plugin.add_plugin_dir(d)
    end
  end
end

@ganmacs
Copy link
Member Author

ganmacs commented Sep 2, 2016

@repeatedly

There are two tests
( https://github.com/fluent/fluentd/pull/1165/files#diff-5e97ad93fa2a92bc851090105261df21R329
and https://github.com/fluent/fluentd/pull/1165/files#diff-5e97ad93fa2a92bc851090105261df21R339) for -p option'.

The first one is a test when two directories are passed.
The second one is a test when a directory is passed.
So I think it is need two directories for a test.

@repeatedly
Copy link
Member

@ganmacs Ah, I see. Got it.

* fix verbose if condition
* use Yajl instead of Oj
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch 4 times, most recently from c7ede42 to 3c9e2a1 Compare September 5, 2016 02:47
@ganmacs ganmacs force-pushed the create-tool-that-load-dumped-event branch from 3c9e2a1 to d128ec5 Compare September 5, 2016 04:23
@ganmacs
Copy link
Member Author

ganmacs commented Sep 5, 2016

@tagomoris @repeatedly
I updated. Please review the code again.

@tagomoris
Copy link
Member

LGTM.

@tagomoris tagomoris merged commit 75005f1 into fluent:master Sep 7, 2016
@ganmacs ganmacs deleted the create-tool-that-load-dumped-event branch November 28, 2019 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants