fluent-plugin-tail-lite 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE +3 -0
- data/README.md +35 -0
- data/Rakefile +11 -0
- data/example.conf +10 -0
- data/fluent-plugin-tail-lite.gemspec +21 -0
- data/lib/fluent/plugin/in_tail_lite.rb +14 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_in_tail_lite.rb +52 -0
- data/test/tmp/tail.txt +4 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Fluent::Plugin::TailLite
|
2
|
+
|
3
|
+
This plugin extendis in_tail to emit each line as it is.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`$ fluent-gem install fluent-plugin-tail-lite`
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
### Example
|
12
|
+
|
13
|
+
```
|
14
|
+
<source>
|
15
|
+
type tail_lite
|
16
|
+
path /var/log/message
|
17
|
+
tag syslog
|
18
|
+
record record
|
19
|
+
</source>
|
20
|
+
```
|
21
|
+
|
22
|
+
### Parameter
|
23
|
+
|
24
|
+
|parameter|description|default|
|
25
|
+
|---|---|---|
|
26
|
+
|field_name|attribute name where lines in log files will go|message|
|
27
|
+
|
28
|
+
in_tail parametes are available in common.
|
29
|
+
|
30
|
+
## Copyright
|
31
|
+
|
32
|
+
<table>
|
33
|
+
<tr><td>Copyright</td><td>Copyright (c) 2013 OKUNO Akihiro</td></tr>
|
34
|
+
<tr><td>License</td><td>Apache License, Version 2.0</td></tr>
|
35
|
+
</table>
|
data/Rakefile
ADDED
data/example.conf
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-tail-lite"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = ["OKUNO Akihiro"]
|
8
|
+
s.email = ["okuno.akihiro@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/choplin/fluent-plugin-tail-lite"
|
10
|
+
s.summary = %q{Fluentd input plugin which read text files and emit each line as it is.}
|
11
|
+
s.description = %q{Fluentd input plugin which read text files and emit each line as it is.}
|
12
|
+
|
13
|
+
s.rubyforge_project = "fluent-plugin-tail-lite"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency "fluentd"
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fluent
|
2
|
+
class TailInputLite < Fluent::TailInput
|
3
|
+
Fluent::Plugin.register_input('tail_lite', self)
|
4
|
+
|
5
|
+
config_param :field_name, :string, :default => 'message'
|
6
|
+
|
7
|
+
def configure_parser(conf)
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse_line(line)
|
11
|
+
return Engine.now, {@field_name => line}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
require 'fluent/plugin/in_tail'
|
25
|
+
require 'fluent/plugin/in_tail_lite'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TailLiteInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
FileUtils.rm_rf(TMP_DIR)
|
7
|
+
FileUtils.mkdir_p(TMP_DIR)
|
8
|
+
end
|
9
|
+
|
10
|
+
TMP_DIR = File.dirname(__FILE__) + "/../tmp"
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
path #{TMP_DIR}/tail.txt
|
14
|
+
tag test
|
15
|
+
field_name record
|
16
|
+
]
|
17
|
+
|
18
|
+
def create_driver(conf=CONFIG)
|
19
|
+
Fluent::Test::InputTestDriver.new(Fluent::TailInputLite).configure(conf)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_configure
|
23
|
+
d = create_driver
|
24
|
+
assert_equal ["#{TMP_DIR}/tail.txt"], d.instance.paths
|
25
|
+
assert_equal "test", d.instance.tag
|
26
|
+
assert_equal "record", d.instance.field_name
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_emit
|
30
|
+
File.open("#{TMP_DIR}/tail.txt", "w") {|f|
|
31
|
+
f.puts "test1"
|
32
|
+
f.puts "test2"
|
33
|
+
}
|
34
|
+
|
35
|
+
d = create_driver
|
36
|
+
|
37
|
+
d.run do
|
38
|
+
sleep 1
|
39
|
+
|
40
|
+
File.open("#{TMP_DIR}/tail.txt", "a") {|f|
|
41
|
+
f.puts "test3"
|
42
|
+
f.puts "test4"
|
43
|
+
}
|
44
|
+
sleep 1
|
45
|
+
end
|
46
|
+
|
47
|
+
emits = d.emits
|
48
|
+
assert_equal(true, emits.length > 0)
|
49
|
+
assert_equal({"record"=>"test3"}, emits[0][2])
|
50
|
+
assert_equal({"record"=>"test4"}, emits[1][2])
|
51
|
+
end
|
52
|
+
end
|
data/test/tmp/tail.txt
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-tail-lite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- OKUNO Akihiro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Fluentd input plugin which read text files and emit each line as it is.
|
31
|
+
email:
|
32
|
+
- okuno.akihiro@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- example.conf
|
43
|
+
- fluent-plugin-tail-lite.gemspec
|
44
|
+
- lib/fluent/plugin/in_tail_lite.rb
|
45
|
+
- test/helper.rb
|
46
|
+
- test/plugin/test_in_tail_lite.rb
|
47
|
+
- test/tmp/tail.txt
|
48
|
+
homepage: https://github.com/choplin/fluent-plugin-tail-lite
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project: fluent-plugin-tail-lite
|
68
|
+
rubygems_version: 1.8.23
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Fluentd input plugin which read text files and emit each line as it is.
|
72
|
+
test_files:
|
73
|
+
- test/helper.rb
|
74
|
+
- test/plugin/test_in_tail_lite.rb
|
75
|
+
- test/tmp/tail.txt
|
76
|
+
has_rdoc:
|