fluent-plugin-hostname 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/VERSION +1 -1
- data/fluent-plugin-hostname.gemspec +2 -2
- data/lib/fluent/plugin/out_hostname.rb +13 -0
- data/test/plugin/test_out_hostname.rb +6 -4
- metadata +9 -3
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-hostname"
|
5
|
-
gem.version = "0.0.
|
5
|
+
gem.version = "0.0.2"
|
6
6
|
gem.authors = ["Tatsuya Fukata"]
|
7
7
|
gem.email = ["tatsuya.fukata@gmail.com"]
|
8
|
-
gem.summary = %q{Fluentd plugin
|
8
|
+
gem.summary = %q{Fluentd plugin put the hostname in the data}
|
9
9
|
gem.description = %q{}
|
10
10
|
gem.homepage = "https://github.com/fukata/fluent-plugin-hostname"
|
11
11
|
|
@@ -9,6 +9,7 @@ class Fluent::HostnameOutput < Fluent::Output
|
|
9
9
|
include Fluent::SetTimeKeyMixin
|
10
10
|
config_set_default :include_time_key, true
|
11
11
|
|
12
|
+
config_param :add_prefix, :string, :default => nil
|
12
13
|
config_param :key_name, :string, :default => 'host'
|
13
14
|
config_param :host, :string, :default => Socket.gethostname
|
14
15
|
|
@@ -18,9 +19,21 @@ class Fluent::HostnameOutput < Fluent::Output
|
|
18
19
|
if @key_name.empty?
|
19
20
|
raise Fluent::ConfigError, "key_name is must not be specified"
|
20
21
|
end
|
22
|
+
|
23
|
+
if @add_prefix
|
24
|
+
@added_prefix_string = @add_prefix + '.'
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def emit(tag, es, chain)
|
29
|
+
if @add_prefix
|
30
|
+
tag = if tag.length > 0
|
31
|
+
@added_prefix_string + tag
|
32
|
+
else
|
33
|
+
@add_prefix
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
es.each do |time,record|
|
25
38
|
record[@key_name] = @host
|
26
39
|
Fluent::Engine.emit(tag, time, record)
|
@@ -9,10 +9,12 @@ class HostnameOutputTest < Test::Unit::TestCase
|
|
9
9
|
host app01.hoge
|
10
10
|
]
|
11
11
|
CONFIG2 = %[
|
12
|
+
add_prefix filtered
|
12
13
|
key_name server
|
13
14
|
host app02.hoge
|
14
15
|
]
|
15
16
|
CONFIG3 = %[
|
17
|
+
add_prefix filtered
|
16
18
|
host app03.hoge
|
17
19
|
]
|
18
20
|
|
@@ -52,13 +54,13 @@ class HostnameOutputTest < Test::Unit::TestCase
|
|
52
54
|
emits = d.emits
|
53
55
|
assert_equal 2, emits.length
|
54
56
|
|
55
|
-
assert_equal 'test', emits[0][0]
|
57
|
+
assert_equal 'filtered.test', emits[0][0]
|
56
58
|
assert_equal time, emits[0][1]
|
57
59
|
assert_equal ['foo','baz','server'], emits[0][2].keys
|
58
60
|
assert_equal 'app02.hoge', emits[0][2]['server']
|
59
61
|
|
60
62
|
|
61
|
-
assert_equal 'test', emits[0][0]
|
63
|
+
assert_equal 'filtered.test', emits[0][0]
|
62
64
|
assert_equal time, emits[0][1]
|
63
65
|
assert_equal ['foo','baz','server'], emits[0][2].keys
|
64
66
|
assert_equal 'app02.hoge', emits[0][2]['server']
|
@@ -74,13 +76,13 @@ class HostnameOutputTest < Test::Unit::TestCase
|
|
74
76
|
emits = d.emits
|
75
77
|
assert_equal 2, emits.length
|
76
78
|
|
77
|
-
assert_equal 'test', emits[0][0]
|
79
|
+
assert_equal 'filtered.test', emits[0][0]
|
78
80
|
assert_equal time, emits[0][1]
|
79
81
|
assert_equal ['foo','baz','host'], emits[0][2].keys
|
80
82
|
assert_equal 'app03.hoge', emits[0][2]['host']
|
81
83
|
|
82
84
|
|
83
|
-
assert_equal 'test', emits[0][0]
|
85
|
+
assert_equal 'filtered.test', emits[0][0]
|
84
86
|
assert_equal time, emits[0][1]
|
85
87
|
assert_equal ['foo','baz','host'], emits[0][2].keys
|
86
88
|
assert_equal 'app03.hoge', emits[0][2]['host']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-hostname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -91,18 +91,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
hash: 4194763417812664163
|
94
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
98
|
none: false
|
96
99
|
requirements:
|
97
100
|
- - ! '>='
|
98
101
|
- !ruby/object:Gem::Version
|
99
102
|
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: 4194763417812664163
|
100
106
|
requirements: []
|
101
107
|
rubyforge_project:
|
102
108
|
rubygems_version: 1.8.23
|
103
109
|
signing_key:
|
104
110
|
specification_version: 3
|
105
|
-
summary: Fluentd plugin
|
111
|
+
summary: Fluentd plugin put the hostname in the data
|
106
112
|
test_files:
|
107
113
|
- test/helper.rb
|
108
114
|
- test/plugin/test_out_hostname.rb
|