fluent-plugin-slack 0.1.0 → 0.1.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 +8 -8
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/fluent-plugin-slack.gemspec +2 -0
- data/lib/fluent/plugin/out_buffered_slack.rb +19 -14
- data/test/plugin/out_buffered_slack.rb +7 -6
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzAwOGJlODQ1MzNhY2U5ZWZlYjg5YzdiYTQzZTdlNDA3NzRmNWQ0OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmNhMzBjM2Y5YThhMWU0YWY1NmVmNDQ0NTA5YjMxNGQzZTcyNDk4OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTUxZmExNjYwOGRhNTY1N2I2NWNjNjc4NTgzZjA2NTFkZTNhM2I4Yzg0NjFh
|
10
|
+
YThhZjE1MmZhOWRjNDFiYzhhZjIxMzRjNjUzNDAwZGM5YWQxOWRhZjJmMGNj
|
11
|
+
YjFlMDJhNzY3MjdhZWUxOWJhM2VhODk2NTgzYjI5ZWQ2NTExMjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjhjODFiMDdkYjBjZTI2YmM5ZDdhYWEwMzBhNzg1ZDEyMmZjYjgwMzlkY2Jj
|
14
|
+
ZmUyZWFkYTU0YWU1ZDVhYzRlNjc2OTU5MGUyNjNhZDJiNThmYWE1YmM2ZWMz
|
15
|
+
M2Q1ZDA2OGM1ODg2YWQ1MDliMzhmZDAxYWUxMDNhZDYyOGNjN2Q=
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/fluent-plugin-slack.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency "fluentd", ">= 0.10.8"
|
19
19
|
gem.add_dependency "slackr", ">= 0.0.2"
|
20
|
+
gem.add_dependency "activesupport", ">=3.2.16"
|
21
|
+
gem.add_dependency "tzinfo", ">=0.3.38"
|
20
22
|
|
21
23
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
22
24
|
gem.add_development_dependency "simplecov", ">= 0.5.4"
|
@@ -7,6 +7,7 @@ module Fluent
|
|
7
7
|
config_param :username, :string
|
8
8
|
config_param :color, :string
|
9
9
|
config_param :icon_emoji, :string
|
10
|
+
config_param :timezone, :string, default: nil
|
10
11
|
|
11
12
|
attr_reader :slack
|
12
13
|
|
@@ -18,40 +19,44 @@ module Fluent
|
|
18
19
|
messages = {}
|
19
20
|
chunk.msgpack_each do |tag, time, record|
|
20
21
|
messages[tag] = '' if messages[tag].nil?
|
21
|
-
messages[tag] << "[#{Time.at(time)}] #{record['message']}\n"
|
22
|
+
messages[tag] << "[#{Time.at(time).in_time_zone(@timezone)}] #{record['message']}\n"
|
22
23
|
end
|
23
24
|
messages.each do |tag, value|
|
24
25
|
field = {
|
25
26
|
title: tag,
|
26
27
|
value: value
|
27
28
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
begin
|
30
|
+
@slack.say(
|
31
|
+
nil,
|
32
|
+
{ channel: @channel,
|
33
|
+
username: @username,
|
34
|
+
icon_emoji: @icon_emoji,
|
35
|
+
attachments: [{
|
36
|
+
fallback: tag,
|
37
|
+
color: @color,
|
38
|
+
fields: [ field ]
|
39
|
+
}]})
|
40
|
+
rescue => e
|
41
|
+
$log.error("Slack Error: #{e.backtrace[0]} / #{e.message}")
|
42
|
+
end
|
38
43
|
end
|
39
|
-
rescue => e
|
40
|
-
$log.error("Slack Error: #{e.backtrace[0]} / #{e.message}")
|
41
44
|
end
|
42
45
|
|
43
46
|
def initialize
|
44
47
|
super
|
48
|
+
require 'active_support/time'
|
45
49
|
require 'slackr'
|
46
50
|
end
|
47
51
|
|
48
52
|
def configure(conf)
|
49
53
|
super
|
50
54
|
@slack = Slackr::Webhook.new(conf['team'], conf['api_key'])
|
51
|
-
@channel =
|
55
|
+
@channel = conf['channel']
|
52
56
|
@username = conf['username'] || 'fluentd'
|
53
57
|
@color = conf['color'] || 'good'
|
54
58
|
@icon_emoji = conf['icon_emoji'] || ':question:'
|
59
|
+
@timezone = conf['timezone'] || 'UTC'
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
@@ -13,10 +13,11 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
|
|
13
13
|
type buffered_slack
|
14
14
|
api_key testtoken
|
15
15
|
team sowasowa
|
16
|
-
channel
|
16
|
+
channel %23test
|
17
17
|
username testuser
|
18
18
|
color good
|
19
19
|
icon_emoji :ghost:
|
20
|
+
timezone Asia/Tokyo
|
20
21
|
compress gz
|
21
22
|
buffer_path ./test/tmp
|
22
23
|
utc
|
@@ -32,7 +33,7 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
|
|
32
33
|
d.tag = 'test'
|
33
34
|
stub(d.instance.slack).say(
|
34
35
|
nil,
|
35
|
-
channel: '
|
36
|
+
channel: '%23test',
|
36
37
|
username: 'testuser',
|
37
38
|
icon_emoji: ':ghost:',
|
38
39
|
attachments: [{
|
@@ -41,7 +42,7 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
|
|
41
42
|
fields: [
|
42
43
|
{
|
43
44
|
title: d.tag,
|
44
|
-
value: "[#{Time.at(time)}] sowawa\n"
|
45
|
+
value: "[#{Time.at(time).in_time_zone('Tokyo')}] sowawa\n"
|
45
46
|
}]}])
|
46
47
|
d.emit({message: 'sowawa'}, time)
|
47
48
|
d.expect_format %[#{['test', time, {message: 'sowawa'}].to_msgpack}]
|
@@ -54,7 +55,7 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
|
|
54
55
|
d.tag = 'test'
|
55
56
|
stub(d.instance.slack).say(
|
56
57
|
nil,
|
57
|
-
channel: '
|
58
|
+
channel: '%23test',
|
58
59
|
username: 'testuser',
|
59
60
|
icon_emoji: ':ghost:',
|
60
61
|
attachments: [{
|
@@ -63,8 +64,8 @@ class BufferedSlackOutputTest < Test::Unit::TestCase
|
|
63
64
|
fields: [
|
64
65
|
{
|
65
66
|
title: d.tag,
|
66
|
-
value: "[#{Time.at(time)}] sowawa1\n" +
|
67
|
-
"[#{Time.at(time)}] sowawa2\n"
|
67
|
+
value: "[#{Time.at(time).in_time_zone('Tokyo')}] sowawa1\n" +
|
68
|
+
"[#{Time.at(time).in_time_zone('Tokyo')}] sowawa2\n"
|
68
69
|
}]}])
|
69
70
|
d.emit({message: 'sowawa1'}, time)
|
70
71
|
d.emit({message: 'sowawa2'}, time)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke SOGAWA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.16
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.16
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tzinfo
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.38
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.38
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|