fluent-plugin-grassland 0.0.5 → 0.2.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 +5 -5
- data/README.md +47 -7
- data/fluent-plugin-grassland.gemspec +3 -3
- data/lib/fluent/plugin/out_grassland.rb +25 -15
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0a58e5705d031e2680d0e20166851d5837aea29de2e0f635700b1b42315849c0
|
4
|
+
data.tar.gz: 925f4f26f5d36c91d06a3f08eb0994a0992a1fb2548af1c5ebc7677c9a0d1cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f376fe29cdc9881dd025c545d98532b05596143841dd28175d514e626d34fe4625569cf5fb68b6cb0bfe450da29a69978c42fca00ff2fbfb65131aeede340eff
|
7
|
+
data.tar.gz: 5e5484eaa1b00cd6d09dd025062e885f78760355946f8f3981f80bffa0491191153af97fff4660d230444cc12297e3b3e3660896bd6cd1c9897ead98928271ca
|
data/README.md
CHANGED
@@ -5,11 +5,12 @@ Output filter plugin for Grassland
|
|
5
5
|
[](http://badge.fury.io/rb/fluent-plugin-grassland)
|
6
6
|
|
7
7
|
## Notice
|
8
|
-
* このアプリケーションはまだテスト中です。
|
9
|
-
|
10
8
|
本アプリケーションはFluentdのGrassland用プラグインです。
|
11
9
|
[Fluentdをインストール](http://docs.fluentd.org/categories/installation)してからご利用下さい。
|
12
10
|
|
11
|
+
[GRASSLANDのWebサイトはこちら](https://grassland.biz/)
|
12
|
+
|
13
|
+
|
13
14
|
## Installation
|
14
15
|
|
15
16
|
__Gemfileに記載する場合__
|
@@ -34,6 +35,8 @@ fluent-gemでインストールします。
|
|
34
35
|
注意: fluent-gemのパスは環境によって異なります。
|
35
36
|
|
36
37
|
$ /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-grassland
|
38
|
+
または、
|
39
|
+
$ /opt/td-agent/embedded/bin/fluent-gem install fluent-plugin-grassland
|
37
40
|
|
38
41
|
## Usage
|
39
42
|
|
@@ -49,7 +52,7 @@ __Fluentdの設定ファイルに以下を追記します。__
|
|
49
52
|
<match grassland.**>
|
50
53
|
type grassland
|
51
54
|
key xxxxxxxxxxxxxxxx
|
52
|
-
flush_interval
|
55
|
+
flush_interval 5
|
53
56
|
</match>
|
54
57
|
```
|
55
58
|
|
@@ -58,7 +61,7 @@ __Fluentdの設定ファイルに以下を追記します。__
|
|
58
61
|
|
59
62
|
__1. [fluent-logger-phpをインストール](https://github.com/fluent/fluent-logger-php)して下さい。__
|
60
63
|
```
|
61
|
-
cat
|
64
|
+
cat > composer.json << EOF
|
62
65
|
{
|
63
66
|
"require": {
|
64
67
|
"fluent/logger": "v0.3.7"
|
@@ -83,8 +86,7 @@ $logger = FluentLogger::open("localhost", "24224");
|
|
83
86
|
|
84
87
|
$param = array(
|
85
88
|
'dt' => 'データID',
|
86
|
-
'
|
87
|
-
'pt' => '(optional)データの発生時刻(ISO 8601準拠の文字列, Ex. "2014-04-01T12:00:00+09:00")',
|
89
|
+
'pt' => '(optional)データの発生時刻(ISO 8601準拠の文字列、又はUnixtimestamp(秒), Ex. "2014-04-01T12:00:00+09:00" or "1432698912")',
|
88
90
|
'd' => array(
|
89
91
|
'任意のキー1' => array('任意のキー2' => '集計を行いたいデータ'),
|
90
92
|
'(optional)任意のキー1' => array('任意のキー2' => '集計を行いたいデータ'),
|
@@ -93,7 +95,7 @@ $param = array(
|
|
93
95
|
);
|
94
96
|
$logger->post("grassland.data", $param);
|
95
97
|
```
|
96
|
-
|
98
|
+
|
97
99
|
ptを省略した場合、fluentdが受け付けた時間のUTC時刻として入力されます。
|
98
100
|
「任意のキー」は、グラフに表示される一つの要素になります。
|
99
101
|
例を以下に示します。
|
@@ -110,4 +112,42 @@ $param = array(
|
|
110
112
|
)
|
111
113
|
);
|
112
114
|
$logger->post("grassland.data", $param);
|
115
|
+
```
|
116
|
+
|
117
|
+
### Node.js usage
|
118
|
+
|
119
|
+
__1. [fluent-logger-nodeをインストール](https://github.com/fluent/fluent-logger-node)して下さい。__
|
120
|
+
```
|
121
|
+
cat > package.json << EOF
|
122
|
+
{
|
123
|
+
"name": "grassland_test ",
|
124
|
+
"version": "0.0.1",
|
125
|
+
"dependencies": {
|
126
|
+
"fluent-logger": "0.2.6"
|
127
|
+
}
|
128
|
+
}
|
129
|
+
EOF
|
130
|
+
npm install
|
131
|
+
```
|
132
|
+
|
133
|
+
__2. 実際にPHPに記載して下さい。__
|
134
|
+
```
|
135
|
+
var logger = require('fluent-logger');
|
136
|
+
logger.configure('grassland', {
|
137
|
+
host: 'localhost',
|
138
|
+
port: 24224,
|
139
|
+
timeout: 3.0
|
140
|
+
});
|
141
|
+
|
142
|
+
/*** ここまでがfluent-loggerの前準備 ***/
|
143
|
+
|
144
|
+
var param = {
|
145
|
+
dt: 'データID',
|
146
|
+
pt: '(optional)データの発生時刻(ISO 8601準拠の文字列 Ex. "2014-04-01T12:00:00+09:00")',
|
147
|
+
d: {
|
148
|
+
'任意のキー1': {'任意のキー2': '(int)集計を行いたいデータ'},
|
149
|
+
'(optional)任意のキー1': {'任意のキー2': '(int)集計を行いたいデータ'}
|
150
|
+
}
|
151
|
+
};
|
152
|
+
logger.emit('data', param);
|
113
153
|
```
|
@@ -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-grassland'
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.2.1'
|
8
8
|
spec.authors = ['Ripplation Inc.']
|
9
9
|
# spec.email = ['xxxxxx@ripplation.co.jp']
|
10
10
|
spec.description = 'Output filter plugin for Grassland'
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
19
|
spec.add_dependency 'fluentd'
|
20
|
-
spec.add_dependency 'eventmachine', '~> 1.
|
21
|
-
spec.add_dependency 'aws-sdk', '~>
|
20
|
+
spec.add_dependency 'eventmachine', '~> 1.2'
|
21
|
+
spec.add_dependency 'aws-sdk', '~> 2'
|
22
22
|
spec.add_dependency 'json'
|
23
23
|
# spec.add_development_dependency 'bundler', '~> 1.3'
|
24
24
|
# spec.add_development_dependency 'rake'
|
@@ -1,6 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'syslog/logger'
|
2
|
+
require 'fluent/plugin/output'
|
3
|
+
|
4
|
+
module Fluent::Plugin
|
5
|
+
class GrasslandOutput < Fluent::Plugin::Output
|
6
|
+
Fluent::Plugin.register_output("grassland", self)
|
4
7
|
|
5
8
|
attr_accessor :random
|
6
9
|
attr_accessor :kinesis
|
@@ -8,6 +11,7 @@ module Fluent
|
|
8
11
|
|
9
12
|
def initialize
|
10
13
|
super
|
14
|
+
# require 'aws-sdk-v1'
|
11
15
|
require 'aws-sdk'
|
12
16
|
require 'base64'
|
13
17
|
require 'json'
|
@@ -15,6 +19,10 @@ module Fluent
|
|
15
19
|
require 'net/http'
|
16
20
|
require 'uri'
|
17
21
|
@random = Random.new
|
22
|
+
|
23
|
+
log = Syslog::Logger.new 'grasslandplugin'
|
24
|
+
log.info 'grassland initialize'
|
25
|
+
# puts "grassland initialize"
|
18
26
|
end
|
19
27
|
|
20
28
|
config_param :apiuri, :string, :default => 'https://grassland.biz/credentials'
|
@@ -59,14 +67,14 @@ module Fluent
|
|
59
67
|
begin
|
60
68
|
setCredential
|
61
69
|
configure_aws
|
62
|
-
|
70
|
+
@kinesis.put_record({
|
63
71
|
:stream_name => @stream_name,
|
64
72
|
:data => "test",
|
65
73
|
:partition_key => "#{random.rand(999)}"
|
66
74
|
})
|
67
|
-
|
75
|
+
log.info "grassland: reset credential"
|
68
76
|
rescue => e
|
69
|
-
|
77
|
+
log.info [e.class, e].join(" : initialize error.")
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
@@ -78,7 +86,7 @@ module Fluent
|
|
78
86
|
@secret_access_key = credential['secretAccessKey']
|
79
87
|
@region = credential['region']
|
80
88
|
@sessionToken = credential['SessionToken']
|
81
|
-
@partitionKeys = credential['
|
89
|
+
@partitionKeys = credential['partitionKeyList']
|
82
90
|
end
|
83
91
|
|
84
92
|
def get_json(location, limit = 3)
|
@@ -99,11 +107,11 @@ module Fluent
|
|
99
107
|
warn "redirected to #{location}"
|
100
108
|
get_json(location, limit - 1)
|
101
109
|
else
|
102
|
-
|
110
|
+
log.info [uri.to_s, response.value].join(" : ")
|
103
111
|
# handle error
|
104
112
|
end
|
105
113
|
rescue => e
|
106
|
-
|
114
|
+
log.info [uri.to_s, e.class, e].join(" : ")
|
107
115
|
# handle error
|
108
116
|
end
|
109
117
|
end
|
@@ -112,7 +120,7 @@ module Fluent
|
|
112
120
|
# print(record)
|
113
121
|
['dt', 'd'].each do |key|
|
114
122
|
unless record.has_key?(key)
|
115
|
-
|
123
|
+
log.info "input data error: '#{key}' is required"
|
116
124
|
return ""
|
117
125
|
end
|
118
126
|
end
|
@@ -138,13 +146,15 @@ module Fluent
|
|
138
146
|
|
139
147
|
begin
|
140
148
|
dataList.each do |data|
|
149
|
+
# debug log
|
150
|
+
# log.info data.to_json
|
141
151
|
if bufList[":#{data['pk']}"] == nil then
|
142
152
|
bufList[":#{data['pk']}"] = "#{data.to_json},"
|
143
153
|
else
|
144
154
|
bufList[":#{data['pk']}"] += "#{data.to_json},"
|
145
155
|
end
|
146
156
|
if bufList[":#{data['pk']}"].bytesize >= 30720 then
|
147
|
-
|
157
|
+
@kinesis.put_record({
|
148
158
|
:stream_name => @stream_name,
|
149
159
|
:data => "["+bufList[":#{data['pk']}"].chop+"]",
|
150
160
|
:partition_key => partitionKeys[random.rand(partitionKeys.length)]
|
@@ -155,7 +165,7 @@ module Fluent
|
|
155
165
|
end
|
156
166
|
dataList.each do |data|
|
157
167
|
if bufList[":#{data['pk']}"] != nil then
|
158
|
-
|
168
|
+
@kinesis.put_record({
|
159
169
|
:stream_name => @stream_name,
|
160
170
|
:data => "["+bufList[":#{data['pk']}"].chop+"]",
|
161
171
|
:partition_key => partitionKeys[random.rand(partitionKeys.length)]
|
@@ -165,7 +175,7 @@ module Fluent
|
|
165
175
|
end
|
166
176
|
end
|
167
177
|
rescue
|
168
|
-
|
178
|
+
log.info "error: put_record to grassland. maybe too many requests. few data dropped."
|
169
179
|
end
|
170
180
|
end
|
171
181
|
|
@@ -187,7 +197,7 @@ module Fluent
|
|
187
197
|
)
|
188
198
|
end
|
189
199
|
|
190
|
-
|
200
|
+
@kinesis = Aws::Kinesis::Client.new(options)
|
191
201
|
end
|
192
202
|
end
|
193
|
-
end
|
203
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-grassland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ripplation Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: eventmachine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aws-sdk
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Output filter plugin for Grassland
|
@@ -72,7 +72,7 @@ executables: []
|
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
|
-
- .gitignore
|
75
|
+
- ".gitignore"
|
76
76
|
- Gemfile
|
77
77
|
- LICENSE.txt
|
78
78
|
- README.md
|
@@ -91,17 +91,16 @@ require_paths:
|
|
91
91
|
- lib
|
92
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.0.14
|
103
|
+
rubygems_version: 3.0.3
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: Output filter plugin for Grassland
|