fluent-plugin-http-pull 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +2 -0
- data/README.md +19 -3
- data/appveyor.yml +23 -0
- data/fluent-plugin-http-pull.gemspec +3 -1
- data/lib/fluent/plugin/in_http_pull.rb +22 -12
- data/test/helper.rb +15 -0
- data/test/plugin/test_in_http_pull.rb +11 -3
- metadata +31 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de0f90b59370bd0d780479ad4326cb3f1cb7a4d
|
4
|
+
data.tar.gz: 5bea27b0f9b1c3fb5e3a593b40c9366f4a651e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f832e52834daa32d1be42df2be0cd836526dadf149a5c9973cc44eb3225b16217ca1926037a2553fdd024450e0eed748c9c02fecb94e1e5f901cc7ab42c031fa
|
7
|
+
data.tar.gz: dca6fe53b789b3b6ed8eb277af015461b0216d2804bf9720244dccfbd8cb817386e46ee520f40c63af7f8dfe192743bbd744f623167e7591000c5a5e2d804f55
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# fluent-plugin-http-pull
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/HatsuneMiku3939/fluent-plugin-http-pull.svg?branch=master)](https://travis-ci.org/HatsuneMiku3939/fluent-plugin-http-pull)
|
4
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/k91x4jyhahoo2it3?svg=true)](https://ci.appveyor.com/project/HatsuneMiku3939/fluent-plugin-http-pull)
|
4
5
|
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-http-pull.svg)](https://badge.fury.io/rb/fluent-plugin-http-pull)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/HatsuneMiku3939/fluent-plugin-http-pull/badge.svg?branch=master)](https://coveralls.io/github/HatsuneMiku3939/fluent-plugin-http-pull?branch=master)
|
5
7
|
|
6
8
|
|
7
9
|
[Fluentd](http://fluentd.org/) input plugin to pull log from rest api.
|
@@ -41,6 +43,7 @@ $ bundle
|
|
41
43
|
url http://www.google.com
|
42
44
|
interval 1s
|
43
45
|
|
46
|
+
format none
|
44
47
|
status_only true
|
45
48
|
</source>
|
46
49
|
|
@@ -68,6 +71,8 @@ $ bundle
|
|
68
71
|
tag fluentd.status
|
69
72
|
url http://localhost:24220/api/plugins.json
|
70
73
|
interval 1s
|
74
|
+
|
75
|
+
format json
|
71
76
|
</source>
|
72
77
|
|
73
78
|
<match fluentd.status>
|
@@ -89,6 +94,8 @@ $ bundle
|
|
89
94
|
tag es.cluster.health
|
90
95
|
url http://localhost:9200/_cluster/health
|
91
96
|
interval 1s
|
97
|
+
|
98
|
+
format json
|
92
99
|
</source>
|
93
100
|
|
94
101
|
<match es.cluster.health>
|
@@ -115,13 +122,22 @@ The url of remote server.
|
|
115
122
|
|
116
123
|
The interval time between periodic request.
|
117
124
|
|
125
|
+
### format (required)
|
126
|
+
|
127
|
+
The format of the response body. Due to limitation of current implement it is
|
128
|
+
always required regardless `status_only` option.
|
129
|
+
|
130
|
+
`http_pull` uses parse plugin to parse the response body. See
|
131
|
+
[parser article](https://docs.fluentd.org/v0.12/articles/parser-plugin-overview)
|
132
|
+
for more detail.
|
133
|
+
|
118
134
|
### status_only (bool) (optional, default: false)
|
119
135
|
|
120
|
-
If
|
136
|
+
If status_only is true, body is not parsed.
|
121
137
|
|
122
|
-
### timeout (
|
138
|
+
### timeout (time) (optional, default: 10s)
|
123
139
|
|
124
|
-
|
140
|
+
The timeout of each request.
|
125
141
|
|
126
142
|
## In case of remote error
|
127
143
|
|
data/appveyor.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
install:
|
4
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
5
|
+
- "%devkit%\\devkitvars.bat"
|
6
|
+
- ruby --version
|
7
|
+
- gem --version
|
8
|
+
- bundle install
|
9
|
+
|
10
|
+
build: off
|
11
|
+
|
12
|
+
test_script:
|
13
|
+
- bundle exec rake test
|
14
|
+
|
15
|
+
branches:
|
16
|
+
only:
|
17
|
+
- master
|
18
|
+
|
19
|
+
# https://www.appveyor.com/docs/installed-software/#ruby
|
20
|
+
environment:
|
21
|
+
matrix:
|
22
|
+
- ruby_version: "23-x64"
|
23
|
+
devkit: C:\Ruby23-x64\DevKit
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-http-pull"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.3.0"
|
7
7
|
spec.authors = ["filepang"]
|
8
8
|
spec.email = ["filepang@gmail.com"]
|
9
9
|
|
@@ -21,8 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_development_dependency "rake", "~> 12.0"
|
24
|
+
spec.add_development_dependency "simplecov", "~> 0.7"
|
24
25
|
spec.add_development_dependency "test-unit", "~> 3.0"
|
25
26
|
spec.add_development_dependency "test-unit-rr", "~> 1.0", "~> 1.0.2"
|
27
|
+
spec.add_development_dependency "coveralls", "~> 0.7"
|
26
28
|
|
27
29
|
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
28
30
|
spec.add_runtime_dependency "rest-client", [">= 2.0.0", "< 3"]
|
@@ -21,7 +21,7 @@ module Fluent
|
|
21
21
|
class HttpPullInput < Fluent::Plugin::Input
|
22
22
|
Fluent::Plugin.register_input("http_pull", self)
|
23
23
|
|
24
|
-
helpers :timer
|
24
|
+
helpers :timer, :parser, :compat_parameters
|
25
25
|
|
26
26
|
def initialize
|
27
27
|
super
|
@@ -29,17 +29,20 @@ module Fluent
|
|
29
29
|
|
30
30
|
desc 'The tag of the event.'
|
31
31
|
config_param :tag, :string
|
32
|
-
desc 'The
|
32
|
+
desc 'The url of monitoring target'
|
33
33
|
config_param :url, :string
|
34
34
|
desc 'The interval time between periodic request'
|
35
35
|
config_param :interval, :time
|
36
36
|
desc 'status_only'
|
37
37
|
config_param :status_only, :bool, default: false
|
38
38
|
desc 'timeout second of each request'
|
39
|
-
config_param :timeout, :
|
39
|
+
config_param :timeout, :time, default: 10
|
40
40
|
|
41
41
|
def configure(conf)
|
42
|
+
compat_parameters_convert(conf, :parser)
|
42
43
|
super
|
44
|
+
|
45
|
+
@parser = parser_create unless @status_only
|
43
46
|
end
|
44
47
|
|
45
48
|
def start
|
@@ -49,28 +52,35 @@ module Fluent
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def on_timer
|
52
|
-
|
55
|
+
record = { "url" => @url }
|
53
56
|
|
54
57
|
begin
|
55
58
|
res = RestClient::Request.execute(method: :get,
|
56
59
|
url: @url,
|
57
60
|
timeout: @timeout)
|
58
|
-
|
59
|
-
|
61
|
+
record["status"] = res.code
|
62
|
+
record["body"] = res.body
|
60
63
|
rescue StandardError => err
|
61
64
|
if err.respond_to? :http_code
|
62
|
-
|
65
|
+
record["status"] = err.http_code || 0
|
63
66
|
else
|
64
|
-
|
67
|
+
record["status"] = 0
|
65
68
|
end
|
66
69
|
|
67
|
-
|
70
|
+
record["error"] = err.message
|
68
71
|
end
|
69
72
|
|
70
|
-
|
71
|
-
|
73
|
+
record_time = Engine.now
|
74
|
+
|
75
|
+
if !@status_only && record["body"] != nil
|
76
|
+
@parser.parse(record["body"]) do |time, message|
|
77
|
+
record["message"] = message
|
78
|
+
record_time = time
|
79
|
+
end
|
80
|
+
end
|
72
81
|
|
73
|
-
|
82
|
+
record.delete("body")
|
83
|
+
router.emit(@tag, record_time, record)
|
74
84
|
end
|
75
85
|
|
76
86
|
def shutdown
|
data/test/helper.rb
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# simplecov must be loaded before any of target code
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter
|
9
|
+
])
|
10
|
+
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/test/'
|
13
|
+
end
|
14
|
+
|
15
|
+
# load our target code
|
1
16
|
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
17
|
require "test-unit"
|
3
18
|
require "fluent/test"
|
@@ -12,7 +12,9 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
12
12
|
TEST_DEFAULT_VALUE_CONFIG = %[
|
13
13
|
tag test
|
14
14
|
url http://127.0.0.1
|
15
|
+
|
15
16
|
interval 3s
|
17
|
+
format json
|
16
18
|
]
|
17
19
|
|
18
20
|
test 'status_only' do
|
@@ -37,6 +39,7 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
37
39
|
timeout 10
|
38
40
|
|
39
41
|
interval 3s
|
42
|
+
format none
|
40
43
|
status_only true
|
41
44
|
]
|
42
45
|
|
@@ -46,6 +49,7 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
46
49
|
timeout 10
|
47
50
|
|
48
51
|
interval 5s
|
52
|
+
format json
|
49
53
|
]
|
50
54
|
|
51
55
|
setup do
|
@@ -99,7 +103,9 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
99
103
|
TEST_REFUSED_CONFIG = %[
|
100
104
|
tag test
|
101
105
|
url http://127.0.0.1:5927
|
102
|
-
interval
|
106
|
+
interval 1s
|
107
|
+
|
108
|
+
format json
|
103
109
|
]
|
104
110
|
test "connection refused by remote" do
|
105
111
|
d = create_driver TEST_REFUSED_CONFIG
|
@@ -126,9 +132,10 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
126
132
|
TEST_TIMEOUT_FAIL_CONFIG = %[
|
127
133
|
tag test
|
128
134
|
url http://127.0.0.1
|
129
|
-
timeout
|
135
|
+
timeout 2s
|
130
136
|
|
131
|
-
interval
|
137
|
+
interval 3s
|
138
|
+
format json
|
132
139
|
]
|
133
140
|
|
134
141
|
setup do
|
@@ -145,6 +152,7 @@ class HttpPullInputTest < Test::Unit::TestCase
|
|
145
152
|
test "timeout" do
|
146
153
|
d = create_driver TEST_TIMEOUT_FAIL_CONFIG
|
147
154
|
assert_equal("test", d.instance.tag)
|
155
|
+
assert_equal(2, d.instance.timeout)
|
148
156
|
|
149
157
|
d.run(timeout: 5) do
|
150
158
|
sleep 7
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-http-pull
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- filepang
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '12.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.7'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: test-unit
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +72,20 @@ dependencies:
|
|
58
72
|
- - "~>"
|
59
73
|
- !ruby/object:Gem::Version
|
60
74
|
version: 1.0.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: coveralls
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.7'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.7'
|
61
89
|
- !ruby/object:Gem::Dependency
|
62
90
|
name: fluentd
|
63
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,12 +133,14 @@ executables: []
|
|
105
133
|
extensions: []
|
106
134
|
extra_rdoc_files: []
|
107
135
|
files:
|
136
|
+
- ".coveralls.yml"
|
108
137
|
- ".gitignore"
|
109
138
|
- ".travis.yml"
|
110
139
|
- Gemfile
|
111
140
|
- LICENSE
|
112
141
|
- README.md
|
113
142
|
- Rakefile
|
143
|
+
- appveyor.yml
|
114
144
|
- fluent-plugin-http-pull.gemspec
|
115
145
|
- lib/fluent/plugin/in_http_pull.rb
|
116
146
|
- test/helper.rb
|