fluent-plugin-slackboard 0.0.1 → 0.1.0
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 +4 -4
- data/README.md +8 -8
- data/fluent-plugin-slackboard.gemspec +1 -1
- data/lib/fluent/plugin/out_slackboard.rb +30 -30
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cfb89c48eedc39c7e8e9fb8dcc15dc9afc37f416
|
|
4
|
+
data.tar.gz: 828caa6564598099c8738745d47ed893628e0818
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da6081bb59758f464629c395387b44963ca31b3960c29b1d420aafa6c144c7f5367792d8b6e09789f1a6d1a7ee3947fc15e83389e80288e5a82f1836627bedd9
|
|
7
|
+
data.tar.gz: 2696f678c15ac4e4376e99f1396af029982ba0e704cd07f1eb1e14860121a675d84c34cee994c7e720e5bff92d80500f00f657e756b31319631f80d537db900e
|
data/README.md
CHANGED
|
@@ -18,15 +18,15 @@ gem install fluent-plugin-slackboard
|
|
|
18
18
|
<match>
|
|
19
19
|
type slackboard
|
|
20
20
|
# required
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
host host
|
|
22
|
+
port port
|
|
23
|
+
channel random
|
|
24
|
+
fetch_key message
|
|
25
25
|
# optional
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
username slackboard
|
|
27
|
+
icon_emoji :clipboard:
|
|
28
|
+
parse true
|
|
29
|
+
sync false
|
|
30
30
|
</match>
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -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-slackboard"
|
|
7
|
-
spec.version = "0.0
|
|
7
|
+
spec.version = "0.1.0"
|
|
8
8
|
spec.authors = ["Tatsuhiko Kubo"]
|
|
9
9
|
spec.email = ["cubicdaiya@gmail.com"]
|
|
10
10
|
spec.summary = %q{plugin for proxying message to slackboard}
|
|
@@ -12,14 +12,14 @@ module Fluent
|
|
|
12
12
|
config_set_default :include_time_key, true
|
|
13
13
|
config_set_default :include_tag_key, true
|
|
14
14
|
|
|
15
|
-
config_param :
|
|
16
|
-
config_param :
|
|
17
|
-
config_param :
|
|
18
|
-
config_param :
|
|
19
|
-
config_param :
|
|
20
|
-
config_param :
|
|
21
|
-
config_param :
|
|
22
|
-
config_param :
|
|
15
|
+
config_param :host, :string, default: "" # slackboard hostname
|
|
16
|
+
config_param :port, :string, default: "" # slackboard port
|
|
17
|
+
config_param :channel, :string, default: "" # slack channel
|
|
18
|
+
config_param :fetch_key, :string, default: "" # fetched key
|
|
19
|
+
config_param :username, :string, default: "" # slack username
|
|
20
|
+
config_param :icon_emoji, :string, default: "" # slack icon emoji
|
|
21
|
+
config_param :parse, :string, default: "full" # parse option for slack
|
|
22
|
+
config_param :sync, :bool, default: false # synchronous proxing
|
|
23
23
|
|
|
24
24
|
def initialize
|
|
25
25
|
super
|
|
@@ -28,31 +28,31 @@ module Fluent
|
|
|
28
28
|
def configure(conf)
|
|
29
29
|
super
|
|
30
30
|
|
|
31
|
-
if @
|
|
32
|
-
raise Fluent::ConfigError.new "`
|
|
31
|
+
if @host == ""
|
|
32
|
+
raise Fluent::ConfigError.new "`host` is empty"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
if @
|
|
36
|
-
raise Fluent::ConfigError.new "`
|
|
35
|
+
if @port == ""
|
|
36
|
+
raise Fluent::ConfigError.new "`port` is empty"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
@
|
|
39
|
+
@uri = URI.parse "http://" + @host + ":" + @port + "/notify-directly"
|
|
40
40
|
|
|
41
|
-
if @
|
|
42
|
-
raise Fluent::ConfigError.new "`
|
|
41
|
+
if @channel == ""
|
|
42
|
+
raise Fluent::ConfigError.new "`channel` is empty"
|
|
43
43
|
end
|
|
44
|
-
@
|
|
44
|
+
@channel = '#' + @channel unless @channel.start_with? '#'
|
|
45
45
|
|
|
46
|
-
if @
|
|
47
|
-
raise Fluent::ConfigError.new "`
|
|
46
|
+
if @fetch_key == ""
|
|
47
|
+
raise Fluent::ConfigError.new "`fetch_key` is empty"
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
if @
|
|
51
|
-
@
|
|
50
|
+
if @username == ""
|
|
51
|
+
@username = "slackboard"
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
if @
|
|
55
|
-
@
|
|
54
|
+
if @icon_emoji == ""
|
|
55
|
+
@icon_emoji = ":clipboard:"
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -64,9 +64,9 @@ module Fluent
|
|
|
64
64
|
begin
|
|
65
65
|
payloads = build_payloads chunk
|
|
66
66
|
payloads.each { |payload|
|
|
67
|
-
req = Net::HTTP::Post.new @
|
|
67
|
+
req = Net::HTTP::Post.new @uri.path
|
|
68
68
|
req.body = payload.to_json
|
|
69
|
-
res = Net::HTTP.start(@
|
|
69
|
+
res = Net::HTTP.start(@uri.host, @uri.port) { |http|
|
|
70
70
|
http.request req
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -86,13 +86,13 @@ module Fluent
|
|
|
86
86
|
chunk.msgpack_each do |tag, time, record|
|
|
87
87
|
payload = {}
|
|
88
88
|
payload["payload"] = {
|
|
89
|
-
:channel => @
|
|
90
|
-
:username => @
|
|
91
|
-
:icon_emoji => @
|
|
92
|
-
:text => record[@
|
|
93
|
-
:parse => @
|
|
89
|
+
:channel => @channel,
|
|
90
|
+
:username => @username,
|
|
91
|
+
:icon_emoji => @icon_emoji,
|
|
92
|
+
:text => record[@fetch_key],
|
|
93
|
+
:parse => @parse,
|
|
94
94
|
}
|
|
95
|
-
payload["sync"] = @
|
|
95
|
+
payload["sync"] = @sync
|
|
96
96
|
payloads << payload
|
|
97
97
|
end
|
|
98
98
|
payloads
|