fluent-plugin-grassland 0.0.4 → 0.2.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 +5 -5
- data/README.md +52 -16
- data/fluent-plugin-grassland.gemspec +3 -3
- data/lib/fluent/plugin/out_grassland.rb +14 -8
- 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: c0a50827624e60eb0a7e3aa7ece74ccb3b4ee63800efe9d5b882fd07667f98c0
|
4
|
+
data.tar.gz: 33dc0fcfe60b74de19c3fdcbca92362aff2bf0a9e4391bbb80a724b8d6685625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ec89f13aeae1939aba751a8e87b03851b7316bfbc772dfab2d6247602d61236c0eaec16eef3bd67f320aa9fc9772849cca6d6f0830b96032296847c6393fcec
|
7
|
+
data.tar.gz: e7272781f77dfbaf0afa8d512e23ac56d8f8e05b0a9732a3ab0c5ad7223ed7af9eacbc763b3020370b30a653110122e3293c1a9b6fb8dcf65c223f11bf0355b5
|
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"
|
@@ -82,19 +85,17 @@ $logger = FluentLogger::open("localhost", "24224");
|
|
82
85
|
/*** ここまでがfluent-logger-php用の前準備 ***/
|
83
86
|
|
84
87
|
$param = array(
|
85
|
-
'cid' => 'お客様ID',
|
86
88
|
'dt' => 'データID',
|
87
|
-
'
|
88
|
-
'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")',
|
89
90
|
'd' => array(
|
90
|
-
|
91
|
-
'任意のキー' => '
|
92
|
-
|
91
|
+
'任意のキー1' => array('任意のキー2' => '集計を行いたいデータ'),
|
92
|
+
'(optional)任意のキー1' => array('任意のキー2' => '集計を行いたいデータ'),
|
93
|
+
...
|
93
94
|
)
|
94
95
|
);
|
95
96
|
$logger->post("grassland.data", $param);
|
96
97
|
```
|
97
|
-
|
98
|
+
|
98
99
|
ptを省略した場合、fluentdが受け付けた時間のUTC時刻として入力されます。
|
99
100
|
「任意のキー」は、グラフに表示される一つの要素になります。
|
100
101
|
例を以下に示します。
|
@@ -104,14 +105,49 @@ ptを省略した場合、fluentdが受け付けた時間のUTC時刻として
|
|
104
105
|
date_default_timezone_set('Asia/Tokyo');
|
105
106
|
|
106
107
|
$param = array(
|
107
|
-
'cid' => 'cid0000001',
|
108
108
|
'dt' => 'd822fab12eeb4db997db87876a082d82',
|
109
|
-
'uid' => 'user001',
|
110
|
-
'pt' => date( DATE_ISO8601, time() ),
|
111
109
|
'd' => array(
|
112
|
-
'item1' => '100',
|
113
|
-
'item2' => '200'
|
110
|
+
'itemGroup1' => array('item1' => '100'),
|
111
|
+
'itemGroup1' => array('item2' => '200')
|
114
112
|
)
|
115
113
|
);
|
116
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);
|
117
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.0
|
7
|
+
spec.version = '0.2.0'
|
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'
|
@@ -4,10 +4,11 @@ module Fluent
|
|
4
4
|
|
5
5
|
attr_accessor :random
|
6
6
|
attr_accessor :kinesis
|
7
|
-
attr_accessor :stream_name, :access_key_id, :secret_access_key, :region, :sessionToken, :partitionKeys
|
7
|
+
attr_accessor :id, :stream_name, :access_key_id, :secret_access_key, :region, :sessionToken, :partitionKeys
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
super
|
11
|
+
# require 'aws-sdk-v1'
|
11
12
|
require 'aws-sdk'
|
12
13
|
require 'base64'
|
13
14
|
require 'json'
|
@@ -18,7 +19,7 @@ module Fluent
|
|
18
19
|
end
|
19
20
|
|
20
21
|
config_param :apiuri, :string, :default => 'https://grassland.biz/credentials'
|
21
|
-
config_param :id, :string, :default => 'nil'
|
22
|
+
# config_param :id, :string, :default => 'nil'
|
22
23
|
config_param :key, :string, :default => 'nil'
|
23
24
|
config_param :debug, :bool, :default => false
|
24
25
|
config_param :resetCredentialTimer, :integer, :default => 86400
|
@@ -59,7 +60,7 @@ module Fluent
|
|
59
60
|
begin
|
60
61
|
setCredential
|
61
62
|
configure_aws
|
62
|
-
|
63
|
+
@kinesis.client.put_record({
|
63
64
|
:stream_name => @stream_name,
|
64
65
|
:data => "test",
|
65
66
|
:partition_key => "#{random.rand(999)}"
|
@@ -72,12 +73,13 @@ module Fluent
|
|
72
73
|
|
73
74
|
def setCredential()
|
74
75
|
credential = get_json("#{@apiuri}?key=#{@key}")
|
76
|
+
@id = credential['id']
|
75
77
|
@stream_name = credential['streamName']
|
76
78
|
@access_key_id = credential['accessKeyId']
|
77
79
|
@secret_access_key = credential['secretAccessKey']
|
78
80
|
@region = credential['region']
|
79
81
|
@sessionToken = credential['SessionToken']
|
80
|
-
@partitionKeys = credential['
|
82
|
+
@partitionKeys = credential['partitionKeyList']
|
81
83
|
end
|
82
84
|
|
83
85
|
def get_json(location, limit = 3)
|
@@ -109,7 +111,7 @@ module Fluent
|
|
109
111
|
|
110
112
|
def format(tag, time, record)
|
111
113
|
# print(record)
|
112
|
-
['dt', '
|
114
|
+
['dt', 'd'].each do |key|
|
113
115
|
unless record.has_key?(key)
|
114
116
|
puts "input data error: '#{key}' is required"
|
115
117
|
return ""
|
@@ -121,6 +123,9 @@ module Fluent
|
|
121
123
|
unless record.has_key?('cid')
|
122
124
|
record['cid'] = @id
|
123
125
|
end
|
126
|
+
unless record.has_key?('uid')
|
127
|
+
record['uid'] = '0'
|
128
|
+
end
|
124
129
|
|
125
130
|
record['pk'] = record['cid'] + record['dt']
|
126
131
|
return "#{record.to_json},"
|
@@ -140,7 +145,7 @@ module Fluent
|
|
140
145
|
bufList[":#{data['pk']}"] += "#{data.to_json},"
|
141
146
|
end
|
142
147
|
if bufList[":#{data['pk']}"].bytesize >= 30720 then
|
143
|
-
|
148
|
+
@kinesis.client.put_record({
|
144
149
|
:stream_name => @stream_name,
|
145
150
|
:data => "["+bufList[":#{data['pk']}"].chop+"]",
|
146
151
|
:partition_key => partitionKeys[random.rand(partitionKeys.length)]
|
@@ -151,7 +156,7 @@ module Fluent
|
|
151
156
|
end
|
152
157
|
dataList.each do |data|
|
153
158
|
if bufList[":#{data['pk']}"] != nil then
|
154
|
-
|
159
|
+
@kinesis.client.put_record({
|
155
160
|
:stream_name => @stream_name,
|
156
161
|
:data => "["+bufList[":#{data['pk']}"].chop+"]",
|
157
162
|
:partition_key => partitionKeys[random.rand(partitionKeys.length)]
|
@@ -183,7 +188,8 @@ module Fluent
|
|
183
188
|
)
|
184
189
|
end
|
185
190
|
|
186
|
-
AWS.
|
191
|
+
@kinesis = AWS::Kinesis::Client.new(options)
|
192
|
+
# AWS.config(options)
|
187
193
|
end
|
188
194
|
end
|
189
195
|
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.0
|
4
|
+
version: 0.2.0
|
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-17 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.1.2
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: Output filter plugin for Grassland
|