fluent-plugin-forest 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -2
- data/fluent-plugin-forest.gemspec +2 -1
- data/lib/fluent/plugin/out_forest.rb +2 -1
- data/test/plugin/test_out_forest.rb +94 -0
- metadata +18 -2
data/README.md
CHANGED
@@ -9,6 +9,10 @@ In template configurations, you can write configuration lines for overall tags b
|
|
9
9
|
|
10
10
|
This plugin helps you if you are writing very long configurations by copy&paste with a little little diff for many tags.
|
11
11
|
|
12
|
+
Other supported placeholders:
|
13
|
+
* \_\_HOSTNAME\_\_
|
14
|
+
* replaced with string specified by 'hostname' configuration value, or (default) result of 'hostname' command
|
15
|
+
|
12
16
|
You SHOULD NOT use ForestOutput for tags increasing infinitly.
|
13
17
|
|
14
18
|
## Configuration
|
@@ -56,7 +60,7 @@ You can write configuration with ForestOutput like below:
|
|
56
60
|
</template>
|
57
61
|
</match>
|
58
62
|
|
59
|
-
If you want to place logs /var/archive for `service.search.**` without compression, `case` directive is useful:
|
63
|
+
If you want to place logs /var/archive for `service.search.**` as filename with hostname, without compression, `case` directive is useful:
|
60
64
|
|
61
65
|
<match service.*>
|
62
66
|
type forest
|
@@ -67,7 +71,7 @@ If you want to place logs /var/archive for `service.search.**` without compressi
|
|
67
71
|
</template>
|
68
72
|
<case search.**>
|
69
73
|
compress no
|
70
|
-
path /var/archive/__TAG__.*.log
|
74
|
+
path /var/archive/__TAG__.__HOSTNAME__.*.log
|
71
75
|
</case>
|
72
76
|
<case *>
|
73
77
|
compress yes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-forest"
|
4
|
-
gem.version = "0.1.
|
4
|
+
gem.version = "0.1.1"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.description = %q{create sub-plugin dynamically per tags, with template configuration and parameters}
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.require_paths = ["lib"]
|
15
15
|
|
16
|
+
gem.add_development_dependency "rake"
|
16
17
|
gem.add_development_dependency "fluentd"
|
17
18
|
gem.add_runtime_dependency "fluentd"
|
18
19
|
end
|
@@ -4,6 +4,7 @@ class Fluent::ForestOutput < Fluent::Output
|
|
4
4
|
config_param :subtype, :string
|
5
5
|
config_param :remove_prefix, :string, :default => nil
|
6
6
|
config_param :add_prefix, :string, :default => nil
|
7
|
+
config_param :hostname, :string, :default => `hostname`.chomp
|
7
8
|
|
8
9
|
def configure(conf)
|
9
10
|
super
|
@@ -50,7 +51,7 @@ class Fluent::ForestOutput < Fluent::Output
|
|
50
51
|
def parameter(tag, e)
|
51
52
|
pairs = {}
|
52
53
|
e.each do |k,v|
|
53
|
-
pairs[k] = v.gsub('__TAG__', tag)
|
54
|
+
pairs[k] = v.gsub('__TAG__', tag).gsub('__HOSTNAME__', @hostname)
|
54
55
|
end
|
55
56
|
Fluent::Config::Element.new('instance', '', pairs, [])
|
56
57
|
end
|
@@ -82,6 +82,100 @@ subtype hoge
|
|
82
82
|
assert_equal 'd.zz', conf['alt_key']
|
83
83
|
end
|
84
84
|
|
85
|
+
def test_spec_hostname
|
86
|
+
d = create_driver %[
|
87
|
+
subtype hoge
|
88
|
+
hostname somehost.local
|
89
|
+
<template>
|
90
|
+
keyx xxxxxx.__HOSTNAME__
|
91
|
+
keyy yyyyyy.__TAG__
|
92
|
+
alt_key a
|
93
|
+
</template>
|
94
|
+
<case xx>
|
95
|
+
keyz z1
|
96
|
+
alt_key b
|
97
|
+
</case>
|
98
|
+
<case yy.**>
|
99
|
+
keyz z2
|
100
|
+
alt_key c
|
101
|
+
</case>
|
102
|
+
<case *>
|
103
|
+
keyz z3
|
104
|
+
alt_key d.__TAG__.__HOSTNAME__
|
105
|
+
</case>
|
106
|
+
]
|
107
|
+
conf = d.instance.spec('xx')
|
108
|
+
assert_equal 'xxxxxx.somehost.local', conf['keyx']
|
109
|
+
assert_equal 'yyyyyy.xx', conf['keyy']
|
110
|
+
assert_equal 'z1', conf['keyz']
|
111
|
+
assert_equal 'b', conf['alt_key']
|
112
|
+
|
113
|
+
conf = d.instance.spec('yy')
|
114
|
+
assert_equal 'xxxxxx.somehost.local', conf['keyx']
|
115
|
+
assert_equal 'yyyyyy.yy', conf['keyy']
|
116
|
+
assert_equal 'z2', conf['keyz']
|
117
|
+
assert_equal 'c', conf['alt_key']
|
118
|
+
|
119
|
+
conf = d.instance.spec('yy.3')
|
120
|
+
assert_equal 'xxxxxx.somehost.local', conf['keyx']
|
121
|
+
assert_equal 'yyyyyy.yy.3', conf['keyy']
|
122
|
+
assert_equal 'z2', conf['keyz']
|
123
|
+
assert_equal 'c', conf['alt_key']
|
124
|
+
|
125
|
+
conf = d.instance.spec('zz')
|
126
|
+
assert_equal 'xxxxxx.somehost.local', conf['keyx']
|
127
|
+
assert_equal 'yyyyyy.zz', conf['keyy']
|
128
|
+
assert_equal 'z3', conf['keyz']
|
129
|
+
assert_equal 'd.zz.somehost.local', conf['alt_key']
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_spec_real_hostname
|
133
|
+
hostname = `hostname`.chomp
|
134
|
+
d = create_driver %[
|
135
|
+
subtype hoge
|
136
|
+
<template>
|
137
|
+
keyx xxxxxx.__HOSTNAME__
|
138
|
+
keyy yyyyyy.__TAG__
|
139
|
+
alt_key a
|
140
|
+
</template>
|
141
|
+
<case xx>
|
142
|
+
keyz z1
|
143
|
+
alt_key b
|
144
|
+
</case>
|
145
|
+
<case yy.**>
|
146
|
+
keyz z2
|
147
|
+
alt_key c
|
148
|
+
</case>
|
149
|
+
<case *>
|
150
|
+
keyz z3
|
151
|
+
alt_key d.__TAG__.__HOSTNAME__
|
152
|
+
</case>
|
153
|
+
]
|
154
|
+
conf = d.instance.spec('xx')
|
155
|
+
assert_equal 'xxxxxx.' + hostname, conf['keyx']
|
156
|
+
assert_equal 'yyyyyy.xx', conf['keyy']
|
157
|
+
assert_equal 'z1', conf['keyz']
|
158
|
+
assert_equal 'b', conf['alt_key']
|
159
|
+
|
160
|
+
conf = d.instance.spec('yy')
|
161
|
+
assert_equal 'xxxxxx.' + hostname, conf['keyx']
|
162
|
+
assert_equal 'yyyyyy.yy', conf['keyy']
|
163
|
+
assert_equal 'z2', conf['keyz']
|
164
|
+
assert_equal 'c', conf['alt_key']
|
165
|
+
|
166
|
+
conf = d.instance.spec('yy.3')
|
167
|
+
assert_equal 'xxxxxx.' + hostname, conf['keyx']
|
168
|
+
assert_equal 'yyyyyy.yy.3', conf['keyy']
|
169
|
+
assert_equal 'z2', conf['keyz']
|
170
|
+
assert_equal 'c', conf['alt_key']
|
171
|
+
|
172
|
+
conf = d.instance.spec('zz')
|
173
|
+
assert_equal 'xxxxxx.' + hostname, conf['keyx']
|
174
|
+
assert_equal 'yyyyyy.zz', conf['keyy']
|
175
|
+
assert_equal 'z3', conf['keyz']
|
176
|
+
assert_equal 'd.zz.' + hostname, conf['alt_key']
|
177
|
+
end
|
178
|
+
|
85
179
|
def test_faild_plant
|
86
180
|
d = create_driver
|
87
181
|
time = Time.parse("2012-01-02 13:14:15").to_i
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-forest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: fluentd
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|