fluent-plugin-pull_forward 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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +92 -0
- data/Rakefile +10 -0
- data/example/simple_in.conf +19 -0
- data/example/simple_out.conf +15 -0
- data/fluent-plugin-pull_forward.gemspec +26 -0
- data/lib/fluent/plugin/in_pull_forward.rb +118 -0
- data/lib/fluent/plugin/out_pull_forward.rb +145 -0
- data/lib/fluent/plugin/webrick_logger_bridge.rb +104 -0
- data/misc/plugin_image.png +0 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_in_pull_forward.rb +5 -0
- data/test/plugin/test_out_pull_forward.rb +5 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f729c6a8875eb13dfef8e811bf6681e62085b46
|
4
|
+
data.tar.gz: 8654a13d126608b371211e873b2741d61380484f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 427df78ec3facb73f152f1f710693c687cccbc6650759678f9d30b1312ca0ea34809cbb54f315b31c321f4dba4d16d590c893d3c9d06226b2cd1eebe5744d90b
|
7
|
+
data.tar.gz: 88fb138607c461e2e4f81854dd40548ef0b9f8d2c31f134443d7340588aca2d1c8aeed77fa1ed27053728abb70183c2c64ba4cc1f4138ddd84658fcf22cde9d7
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012- TAGOMORI Satoshi
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# fluent-plugin-pull_forward
|
2
|
+
|
3
|
+
[Fluentd](http://fluentd.org) input/output plugin to forward data, by pulling/request-based transportation, over HTTPS.
|
4
|
+
|
5
|
+
We can do with pull_forward:
|
6
|
+
* transfer data into hosts in firewall by pulling
|
7
|
+
* protect transferring route by HTTPS and basic authentication
|
8
|
+
* fetch Fluentd events as JSON by HTTPS from any processes
|
9
|
+
|
10
|
+

|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
### PullForwardOutput
|
15
|
+
|
16
|
+
Configure output plugin to transfer fluentd events to another fluentd nodes.
|
17
|
+
|
18
|
+
```apache
|
19
|
+
<match dummy>
|
20
|
+
type pull_forward
|
21
|
+
|
22
|
+
buffer_path /home/myname/tmp/fluentd_event.buffer
|
23
|
+
flush_interval 1m ## default 1h
|
24
|
+
|
25
|
+
self_hostname ${hostname}
|
26
|
+
cert_auto_generate yes
|
27
|
+
# or
|
28
|
+
# "cert_file_path PATH", "private_key_path PATH" and "private_key_passphrase ..."
|
29
|
+
|
30
|
+
<user>
|
31
|
+
username tagomoris
|
32
|
+
password foobar
|
33
|
+
</user>
|
34
|
+
<user>
|
35
|
+
username repeatedly
|
36
|
+
password booo
|
37
|
+
</user>
|
38
|
+
</match>
|
39
|
+
```
|
40
|
+
|
41
|
+
PullForwardOutput uses PullPoolBuffer plugin. **DO NOT MODIFY buffer_type**. It uses buffer file, so `buffer_path` is required, and Not so short values are welcome for `flush_interval` because PullPoolBuffer make a file per flushes (and these are not removed until fetches of cluent/in\_pull\_forward).
|
42
|
+
|
43
|
+
PullForward always requires SSL and basic authentication. SSL options and `<user>` sections are also required.
|
44
|
+
|
45
|
+
### PullForwardInput
|
46
|
+
|
47
|
+
Configure input plugin to fetch fluentd events from another fluentd nodes.
|
48
|
+
|
49
|
+
```apache
|
50
|
+
<source>
|
51
|
+
type pull_forward
|
52
|
+
|
53
|
+
fetch_interval 10s
|
54
|
+
timeout 10s
|
55
|
+
|
56
|
+
<server>
|
57
|
+
host host1.on.internet.example.com
|
58
|
+
username tagomoris
|
59
|
+
password foobar
|
60
|
+
</server>
|
61
|
+
<server>
|
62
|
+
host host2.on.internet.example.com
|
63
|
+
username tagomoris
|
64
|
+
password foobar
|
65
|
+
</server>
|
66
|
+
</source>
|
67
|
+
```
|
68
|
+
|
69
|
+
PullForwardInput can fetch events from many nodes of `<server>`.
|
70
|
+
|
71
|
+
### HTTPS fetch
|
72
|
+
|
73
|
+
We can fluentd events from PullForwardOutput by normal HTTPS.
|
74
|
+
|
75
|
+
```
|
76
|
+
$ curl -k -s --user tagomoris:foobar https://localhost:24280/
|
77
|
+
[
|
78
|
+
[ "test.foo", 1406915165, { "pos": 8, "hoge": 1 } ],
|
79
|
+
[ "test.foo", 1406915168, { "pos": 9, "hoge": 1 } ],
|
80
|
+
[ "test.foo", 1406915173, { "pos": 0, "hoge": 0 } ]
|
81
|
+
]
|
82
|
+
```
|
83
|
+
|
84
|
+
## TODO
|
85
|
+
|
86
|
+
* TESTS!
|
87
|
+
|
88
|
+
## Copyright
|
89
|
+
|
90
|
+
* Copyright (c) 2014- TAGOMORI Satoshi (tagomoris)
|
91
|
+
* License
|
92
|
+
* Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<source>
|
2
|
+
type pull_forward
|
3
|
+
fetch_interval 10s
|
4
|
+
timeout 10s
|
5
|
+
<server>
|
6
|
+
host localhost
|
7
|
+
username moris
|
8
|
+
password foobar
|
9
|
+
</server>
|
10
|
+
<server>
|
11
|
+
host localhost
|
12
|
+
username moris
|
13
|
+
password fooba
|
14
|
+
</server>
|
15
|
+
</source>
|
16
|
+
|
17
|
+
<match test.**>
|
18
|
+
type stdout
|
19
|
+
</match>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<source>
|
2
|
+
type forward
|
3
|
+
</source>
|
4
|
+
|
5
|
+
<match test.**>
|
6
|
+
type pull_forward
|
7
|
+
buffer_path /tmp/pullforward.buffer.log
|
8
|
+
self_hostname ${hostname}
|
9
|
+
cert_auto_generate yes
|
10
|
+
flush_interval 30s
|
11
|
+
<user>
|
12
|
+
username moris
|
13
|
+
password foobar
|
14
|
+
</user>
|
15
|
+
</match>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "fluent-plugin-pull_forward"
|
5
|
+
spec.version = "0.0.1"
|
6
|
+
spec.authors = ["TAGOMORI Satoshi"]
|
7
|
+
spec.email = ["tagomoris@gmail.com"]
|
8
|
+
spec.summary = %q{Fluentd plugin to forward data, by pulling from input plugin}
|
9
|
+
spec.description = %q{Fluentd plugin that store data to be forwarded, and send these when client(input plugin) requests it, over HTTPS and authentication}
|
10
|
+
spec.homepage = "https://github.com/tagomoris/fluent-plugin-pull_forward"
|
11
|
+
spec.license = "APLv2"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "fluentd"
|
22
|
+
spec.add_runtime_dependency "fluent-plugin-buffer-pullpool"
|
23
|
+
spec.add_runtime_dependency "fluent-mixin-config-placeholders"
|
24
|
+
spec.add_runtime_dependency "fluent-mixin-certificate"
|
25
|
+
spec.add_runtime_dependency "resolve-hostname", ">= 0.0.4"
|
26
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module Fluent
|
2
|
+
class PullForwardInput < Input
|
3
|
+
DEFAULT_PULLFORWARD_LISTEN_PORT = 24280
|
4
|
+
|
5
|
+
Fluent::Plugin.register_input('pull_forward', self)
|
6
|
+
|
7
|
+
config_param :allow_self_signed_certificate, :bool, :default => true
|
8
|
+
|
9
|
+
config_param :fetch_interval, :time, :default => 600 # 10m
|
10
|
+
config_param :timeout, :time, :default => 60
|
11
|
+
|
12
|
+
config_section :server, param_name: :servers do
|
13
|
+
config_param :host, :string
|
14
|
+
config_param :port, :integer, :default => DEFAULT_PULLFORWARD_LISTEN_PORT
|
15
|
+
config_param :username, :string
|
16
|
+
config_param :password, :string
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :hostname_resolver
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
require 'resolve/hostname'
|
24
|
+
require 'net/http'
|
25
|
+
require 'net/https'
|
26
|
+
require 'openssl'
|
27
|
+
require 'yajl'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Define `log` method for v0.10.42 or earlier
|
31
|
+
unless method_defined?(:log)
|
32
|
+
define_method("log") { $log }
|
33
|
+
end
|
34
|
+
|
35
|
+
def configure(conf)
|
36
|
+
super
|
37
|
+
|
38
|
+
@verify_mode = if @allow_self_signed_certificate
|
39
|
+
OpenSSL::SSL::VERIFY_NONE
|
40
|
+
else
|
41
|
+
OpenSSL::SSL::VERIFY_PEER
|
42
|
+
end
|
43
|
+
@resolver = Resolve::Hostname.new(:system_resolver => true)
|
44
|
+
end
|
45
|
+
|
46
|
+
def start
|
47
|
+
super
|
48
|
+
@running = true
|
49
|
+
@thread = Thread.new(&method(:fetcher))
|
50
|
+
end
|
51
|
+
|
52
|
+
def shutdown
|
53
|
+
super
|
54
|
+
@running = false
|
55
|
+
@thread.join
|
56
|
+
end
|
57
|
+
|
58
|
+
def fetcher
|
59
|
+
next_fetch = Time.now
|
60
|
+
while @running
|
61
|
+
if Time.now >= next_fetch
|
62
|
+
@servers.each do |server|
|
63
|
+
if @running
|
64
|
+
fetch(server)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
next_fetch = Time.now + @fetch_interval
|
68
|
+
end
|
69
|
+
break unless @running
|
70
|
+
sleep 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def fetch(server)
|
75
|
+
body = nil
|
76
|
+
|
77
|
+
begin
|
78
|
+
address = @resolver.getaddress(server.host)
|
79
|
+
https = Net::HTTP.new(address, server.port)
|
80
|
+
https.open_timeout = @timeout
|
81
|
+
https.read_timeout = @timeout
|
82
|
+
https.use_ssl = true
|
83
|
+
https.verify_mode = @verify_mode
|
84
|
+
|
85
|
+
req = Net::HTTP::Get.new('/')
|
86
|
+
req.basic_auth server.username, server.password
|
87
|
+
|
88
|
+
res = https.start{ https.request(req) }
|
89
|
+
if res && res.is_a?(Net::HTTPSuccess)
|
90
|
+
body = res.body
|
91
|
+
else
|
92
|
+
log.warn "failed to GET from Fluentd PullForward: #{server.host}, #{address}:#{server.port}, by #{res.class}"
|
93
|
+
end
|
94
|
+
rescue IOError, EOFError, SystemCallError => e
|
95
|
+
log.warn "net/http GET raised an exception: #{e.class}, '#{e.message}'"
|
96
|
+
end
|
97
|
+
return unless body
|
98
|
+
|
99
|
+
data = nil
|
100
|
+
begin
|
101
|
+
data = Yajl::Parser.parse(body)
|
102
|
+
rescue => e
|
103
|
+
# maybe parse error
|
104
|
+
log.warn "an error occured for parse of transferred content: #{e.class}, '#{e.message}'"
|
105
|
+
end
|
106
|
+
return unless data
|
107
|
+
|
108
|
+
bundle = {}
|
109
|
+
data.each do |tag, time, record|
|
110
|
+
bundle[tag] ||= Fluent::MultiEventStream.new
|
111
|
+
bundle[tag].add(time, record)
|
112
|
+
end
|
113
|
+
bundle.each do |tag, es|
|
114
|
+
Fluent::Engine.emit_stream(tag, es)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'fluent/mixin/config_placeholders'
|
2
|
+
require 'fluent/mixin/certificate'
|
3
|
+
require 'webrick'
|
4
|
+
require 'webrick/https'
|
5
|
+
|
6
|
+
require_relative 'webrick_logger_bridge'
|
7
|
+
|
8
|
+
module Fluent
|
9
|
+
class PullForwardOutput < BufferedOutput
|
10
|
+
DEFAULT_PULLFORWARD_LISTEN_PORT = 24280
|
11
|
+
|
12
|
+
Fluent::Plugin.register_output('pull_forward', self)
|
13
|
+
|
14
|
+
config_param :self_hostname, :string
|
15
|
+
include Fluent::Mixin::ConfigPlaceholders
|
16
|
+
|
17
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
18
|
+
config_param :port, :integer, :default => DEFAULT_PULLFORWARD_LISTEN_PORT
|
19
|
+
|
20
|
+
config_param :server_loglevel, :string, :default => 'WARN'
|
21
|
+
config_param :auth_loglevel, :string, :default => 'FATAL'
|
22
|
+
|
23
|
+
config_set_default :buffer_type, 'pullpool'
|
24
|
+
config_set_default :flush_interval, 3600 # 1h
|
25
|
+
|
26
|
+
# REQUIRED: buffer_path
|
27
|
+
|
28
|
+
# same with TimeSlicedOutput + FileBuffer
|
29
|
+
# 16MB * 256 -> 4096MB
|
30
|
+
config_set_default :buffer_chunk_limit, 1024 * 1024 * 16 # 16MB
|
31
|
+
config_set_default :buffer_queue_limit, 256
|
32
|
+
|
33
|
+
include Fluent::Mixin::Certificate
|
34
|
+
# REQUIRED: self_hostname
|
35
|
+
# REQUIRED: 'cert_auto_generate yes' or 'cert_file_path PATH'
|
36
|
+
|
37
|
+
config_section :user, param_name: :users do
|
38
|
+
config_param :username, :string
|
39
|
+
config_param :password, :string
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
unless method_defined?(:log)
|
47
|
+
define_method("log") { $log }
|
48
|
+
end
|
49
|
+
|
50
|
+
def configure(conf)
|
51
|
+
super
|
52
|
+
if @users.size < 1
|
53
|
+
raise Fluent::ConfigError, "no <user> sections specified"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def start
|
58
|
+
super
|
59
|
+
@thread = Thread.new(&method(:run))
|
60
|
+
end
|
61
|
+
|
62
|
+
def shutdown
|
63
|
+
@server.stop if @server
|
64
|
+
@thread.kill
|
65
|
+
@thread.join
|
66
|
+
end
|
67
|
+
|
68
|
+
class HtpasswdDummy < WEBrick::HTTPAuth::Htpasswd
|
69
|
+
# overwrite constructor NOT to generate htpasswd file on local filesystem
|
70
|
+
def initialize
|
71
|
+
@path = '/'
|
72
|
+
@mtime = Time.at(0)
|
73
|
+
@passwd = Hash.new
|
74
|
+
@auth_type = WEBrick::HTTPAuth::BasicAuth
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def run
|
79
|
+
cert, key = self.certificate
|
80
|
+
realm = "Fluentd fluent-plugin-pullforward server"
|
81
|
+
|
82
|
+
logger = $log
|
83
|
+
auth_logger = Fluent::PluginLogger.new(logger)
|
84
|
+
auth_logger.level = @auth_loglevel
|
85
|
+
server_logger = Fluent::PluginLogger.new(logger)
|
86
|
+
server_logger.level = @server_loglevel
|
87
|
+
|
88
|
+
auth_db = HtpasswdDummy.new
|
89
|
+
@users.each do |user|
|
90
|
+
auth_db.set_passwd(realm, user.username, user.password)
|
91
|
+
end
|
92
|
+
authenticator = WEBrick::HTTPAuth::BasicAuth.new(
|
93
|
+
:UserDB => auth_db,
|
94
|
+
:Realm => realm,
|
95
|
+
:Logger => Fluent::PullForward::WEBrickLogger.new(auth_logger),
|
96
|
+
)
|
97
|
+
|
98
|
+
@server = WEBrick::HTTPServer.new(
|
99
|
+
:BindAddress => @bind,
|
100
|
+
:Port => @port,
|
101
|
+
# :DocumentRoot => '.',
|
102
|
+
:Logger => Fluent::PullForward::WEBrickLogger.new(server_logger),
|
103
|
+
:AccessLog => [],
|
104
|
+
:SSLEnable => true,
|
105
|
+
:SSLCertificate => cert,
|
106
|
+
:SSLPrivateKey => key
|
107
|
+
)
|
108
|
+
@server.logger.info("hogepos")
|
109
|
+
|
110
|
+
@server.mount_proc('/') do |req, res|
|
111
|
+
unless req.ssl?
|
112
|
+
raise WEBrick::HTTPStatus::Forbidden, "pullforward plugin does not permit non-HTTPS requests"
|
113
|
+
end
|
114
|
+
if req.path != '/'
|
115
|
+
raise WEBrick::HTTPStatus::NotFound, "valid path is only '/'"
|
116
|
+
end
|
117
|
+
authenticator.authenticate(req, res)
|
118
|
+
res.content_type = 'application/json'
|
119
|
+
res.body = dequeue_chunks()
|
120
|
+
end
|
121
|
+
|
122
|
+
log.info "listening pullforward socket on #{@bind}:#{@port}"
|
123
|
+
@server.start
|
124
|
+
end
|
125
|
+
|
126
|
+
def format(tag, time, record)
|
127
|
+
[tag, time, record].to_msgpack
|
128
|
+
end
|
129
|
+
|
130
|
+
def dequeue_chunks
|
131
|
+
response = []
|
132
|
+
|
133
|
+
unpacker = MessagePack::Unpacker.new
|
134
|
+
|
135
|
+
@buffer.pull_chunks do |chunk|
|
136
|
+
next if chunk.empty?
|
137
|
+
unpacker.feed_each(chunk.read) do |ary|
|
138
|
+
response << ary
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
response.to_json
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Fluent
|
3
|
+
module PullForward
|
4
|
+
class WEBrickLogger
|
5
|
+
FATAL = 1
|
6
|
+
ERROR = 2
|
7
|
+
WARN = 3
|
8
|
+
INFO = 4
|
9
|
+
DEBUG = 5
|
10
|
+
|
11
|
+
def initialize(logger)
|
12
|
+
@logger = logger
|
13
|
+
end
|
14
|
+
|
15
|
+
def <<(str)
|
16
|
+
self.log(INFO, str.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
def close
|
20
|
+
# NOP
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug(msg)
|
24
|
+
self.log(DEBUG, msg)
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug?
|
28
|
+
@logger.level > Fluent::Log::LEVEL_TRACE
|
29
|
+
end
|
30
|
+
|
31
|
+
def error(msg)
|
32
|
+
self.log(ERROR, msg)
|
33
|
+
end
|
34
|
+
|
35
|
+
def error?
|
36
|
+
@logger.level > Fluent::Log::LEVEL_WARN
|
37
|
+
end
|
38
|
+
|
39
|
+
def fatal(msg)
|
40
|
+
self.log(FATAL, msg)
|
41
|
+
end
|
42
|
+
|
43
|
+
def fatal?
|
44
|
+
@logger.level > Fluent::Log::LEVEL_ERROR
|
45
|
+
end
|
46
|
+
|
47
|
+
def info(msg)
|
48
|
+
self.log(INFO, msg)
|
49
|
+
end
|
50
|
+
|
51
|
+
def info?
|
52
|
+
@logger.level > Fluent::Log::LEVEL_DEBUG
|
53
|
+
end
|
54
|
+
|
55
|
+
def level
|
56
|
+
# (Fluentd logger level num) -> (Webrick level num)
|
57
|
+
# 5 -> 1
|
58
|
+
# 4 -> 2
|
59
|
+
# 3 -> 3
|
60
|
+
# 2 -> 4
|
61
|
+
# 1 -> 5
|
62
|
+
# (6 - level)
|
63
|
+
6 - @logger.level
|
64
|
+
end
|
65
|
+
|
66
|
+
def level=(lv)
|
67
|
+
@logger.level = case lv
|
68
|
+
when FATAL then 'fatal'
|
69
|
+
when ERROR then 'error'
|
70
|
+
when WARN then 'warn'
|
71
|
+
when INFO then 'info'
|
72
|
+
when DEBUG then 'debug'
|
73
|
+
else
|
74
|
+
raise ArgumentError, "Invalid loglevel for webrick bridge logger: #{lv}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def log(level, msg)
|
79
|
+
case level
|
80
|
+
when FATAL
|
81
|
+
@logger.fatal(msg)
|
82
|
+
when ERROR
|
83
|
+
@logger.error(msg)
|
84
|
+
when WARN
|
85
|
+
@logger.warn(msg)
|
86
|
+
when INFO
|
87
|
+
@logger.info(msg)
|
88
|
+
when DEBUG
|
89
|
+
@logger.debug(msg)
|
90
|
+
else
|
91
|
+
raise ArgumentError, "Invalid loglevel for webrick bridge logger: #{lv}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def warn(msg)
|
96
|
+
self.log(WARN, msg)
|
97
|
+
end
|
98
|
+
|
99
|
+
def warn?
|
100
|
+
@logger.level > Fluent::Log::LEVEL_INFO
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
Binary file
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
+
|
25
|
+
require 'fluent/plugin/in_pull_forward'
|
26
|
+
require 'fluent/plugin/out_pull_forward'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-pull_forward
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TAGOMORI Satoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluent-plugin-buffer-pullpool
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fluent-mixin-config-placeholders
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fluent-mixin-certificate
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: resolve-hostname
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.0.4
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.4
|
111
|
+
description: Fluentd plugin that store data to be forwarded, and send these when client(input
|
112
|
+
plugin) requests it, over HTTPS and authentication
|
113
|
+
email:
|
114
|
+
- tagomoris@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- example/simple_in.conf
|
125
|
+
- example/simple_out.conf
|
126
|
+
- fluent-plugin-pull_forward.gemspec
|
127
|
+
- lib/fluent/plugin/in_pull_forward.rb
|
128
|
+
- lib/fluent/plugin/out_pull_forward.rb
|
129
|
+
- lib/fluent/plugin/webrick_logger_bridge.rb
|
130
|
+
- misc/plugin_image.png
|
131
|
+
- test/helper.rb
|
132
|
+
- test/plugin/test_in_pull_forward.rb
|
133
|
+
- test/plugin/test_out_pull_forward.rb
|
134
|
+
homepage: https://github.com/tagomoris/fluent-plugin-pull_forward
|
135
|
+
licenses:
|
136
|
+
- APLv2
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.2.2
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Fluentd plugin to forward data, by pulling from input plugin
|
158
|
+
test_files:
|
159
|
+
- test/helper.rb
|
160
|
+
- test/plugin/test_in_pull_forward.rb
|
161
|
+
- test/plugin/test_out_pull_forward.rb
|
162
|
+
has_rdoc:
|