fluent-plugin-idobata 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/fluent-plugin-idobata.gemspec +1 -1
- data/lib/fluent/plugin/out_idobata.rb +33 -2
- data/spec/lib/fluent/plugin/out_idobata_spec.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db215c376fba35b2a596e0ab4ed9c247ff62b3db
|
4
|
+
data.tar.gz: 8613df1e1d57910f45ac478ee8846aa6c1e9e414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed4df2fa7e27ca10ab3720de6805ca4a1bc2bacb9d34eddd7bdc7ac809dc5228080ab5cd6e931735d0fe0ae780eb55b5fe8bf137e2f81c19b1b79fd5ca1a6bfb
|
7
|
+
data.tar.gz: fca15a8f77aef22ff0c5c84b93b29049991253bee5d3d188b16fe1d56017fe98671647278336faf23d805b9fbde04738382705c4e36c973b6ab956b01205a75f
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ see: https://idobata.io
|
|
25
25
|
- message_template
|
26
26
|
- You can use erb notation
|
27
27
|
- send message to idobata
|
28
|
+
- (optional)post_interval
|
29
|
+
- Internal of post to idobata
|
28
30
|
|
29
31
|
#### example
|
30
32
|
|
@@ -43,3 +45,4 @@ send 'field1 is 300 !' message to your idobata room
|
|
43
45
|
## releases
|
44
46
|
|
45
47
|
- 2013/10/09 0.0.0 1st release
|
48
|
+
- 2014/01/21 0.0.1 Support post interval
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-idobata"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.1'
|
8
8
|
spec.authors = ["bash0C7"]
|
9
9
|
spec.email = ["koshiba+github@4038nullpointer.com"]
|
10
10
|
spec.description = "Fluentd output plugin to send data to idobata"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'erb'
|
3
|
+
require 'ostruct'
|
3
4
|
|
4
5
|
module Fluent
|
5
6
|
class Fluent::IdobataOutput < Fluent::Output
|
@@ -11,29 +12,59 @@ module Fluent
|
|
11
12
|
|
12
13
|
config_param :webhook_url, :string
|
13
14
|
config_param :message_template, :string
|
15
|
+
config_param :post_interval, :integer, :default => 1
|
14
16
|
|
15
17
|
def configure(conf)
|
16
18
|
super
|
17
19
|
|
18
20
|
@erb = ERB.new(@message_template)
|
21
|
+
@q = Queue.new
|
19
22
|
end
|
20
23
|
|
21
24
|
def start
|
22
25
|
super
|
23
26
|
|
27
|
+
@thread = Thread.new(&method(:post))
|
28
|
+
rescue
|
29
|
+
$log.warn "raises exception: #{$!.class}, '#{$!.message}"
|
24
30
|
end
|
25
31
|
|
26
32
|
def shutdown
|
27
33
|
super
|
28
34
|
|
35
|
+
Thread.kill(@thread)
|
29
36
|
end
|
30
37
|
|
31
38
|
def emit(tag, es, chain)
|
32
|
-
es.each {|time,record|
|
33
|
-
|
39
|
+
es.each {|time, record|
|
40
|
+
param = OpenStruct.new
|
41
|
+
param.tag = tag
|
42
|
+
param.time = time
|
43
|
+
param.record = record
|
44
|
+
|
45
|
+
@q.push param
|
34
46
|
}
|
35
47
|
|
36
48
|
chain.next
|
37
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def post
|
54
|
+
loop do
|
55
|
+
param = @q.pop
|
56
|
+
tag = param.tag
|
57
|
+
time = param.time
|
58
|
+
record = param.record
|
59
|
+
|
60
|
+
begin
|
61
|
+
HTTParty.post(@webhook_url, :body => "body=#{@erb.result(binding)}")
|
62
|
+
sleep(@post_interval)
|
63
|
+
rescue
|
64
|
+
$log.warn "raises exception: #{$!.class}, '#{$!.message}, #{param}'"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
38
69
|
end
|
39
70
|
end
|
@@ -25,12 +25,17 @@ describe do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe 'emit' do
|
28
|
-
let(:
|
28
|
+
let(:record1) {{ 'field1' => 50, 'otherfield' => 99}}
|
29
|
+
let(:record2) {{ 'field1' => 150, 'otherfield' => 199}}
|
29
30
|
let(:time) {0}
|
30
31
|
let(:posted) {
|
31
32
|
d = driver
|
33
|
+
|
32
34
|
mock(HTTParty).post('https://idobata/web_hook/url', :body => 'body=field1 value: 50')
|
33
|
-
|
35
|
+
mock(HTTParty).post('https://idobata/web_hook/url', :body => 'body=field1 value: 150')
|
36
|
+
|
37
|
+
d.emit(record1, Time.at(time))
|
38
|
+
d.emit(record2, Time.at(time))
|
34
39
|
d.run
|
35
40
|
}
|
36
41
|
|
@@ -39,6 +44,7 @@ describe do
|
|
39
44
|
%[
|
40
45
|
webhook_url https://idobata/web_hook/url
|
41
46
|
message_template field1 value: <%= record["field1"] %>
|
47
|
+
post_interval 0
|
42
48
|
]
|
43
49
|
}
|
44
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-idobata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bash0C7
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|