fluent-plugin-grassland 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e10bd0b1a85a01a7616dc21c1a9e9261b19f47e
4
- data.tar.gz: bbd45daf68b7942c93a28df29d61d850b8ecda43
3
+ metadata.gz: 9b012fd760e3516bfda38ae05c4023cc847511af
4
+ data.tar.gz: 10cf5a7ab421364b7881a289f4a568c7df8c3b07
5
5
  SHA512:
6
- metadata.gz: b82c463cc33c0441c3e4720120de0620b7a929203b3b3dfd3e3c84936c9efcadcafdcaa4c5ba1280a2364b41ccda6e1b2f19eb1f3cf2ef5a5d620dd0750b9f36
7
- data.tar.gz: ad963e16c0e017bdaa50535deee4ab3fbc62bfed396180e1916dfc5da07d2061fd9a13bf070e94c20cc8a3cd799f670fdcc77f9e96268a67c6fe15cca8aac6cb
6
+ metadata.gz: f06c72fa10e193da42ad7431a92d202a96305b9ca95ae0f80d804440a1cd7b2c53b449ea3c971005712fcc120880fe8544ac3096ac6fdf4c4fd81098ed7c0cdb
7
+ data.tar.gz: ec306504bfc139a5df78a61efe7061e942e102b579e2c0affe560ec9d93f9a29657cd08518f0f7c0e4978503f62d37d00f07f70acb3a8f2ebf7dd797ebf144e6
data/README.md CHANGED
@@ -58,7 +58,7 @@ __Fluentdの設定ファイルに以下を追記します。__
58
58
 
59
59
  __1. [fluent-logger-phpをインストール](https://github.com/fluent/fluent-logger-php)して下さい。__
60
60
  ```
61
- cat > composer.json << EOF
61
+ cat >> composer.json << EOF
62
62
  {
63
63
  "require": {
64
64
  "fluent/logger": "v0.3.7"
@@ -85,12 +85,33 @@ $param = array(
85
85
  'cid' => 'お客様ID',
86
86
  'dt' => 'データID',
87
87
  'uid' => 'お客様のサービスのユーザID',
88
- 'pt' => '(optional)データの発生時刻(ISO 8601準拠の文字列か、Unix Timestamp)',
88
+ 'pt' => '(optional)データの発生時刻(ISO 8601準拠の文字列, Ex. "2014-04-01T12:00:00+09:00")',
89
89
  'd' => array(
90
- 'd1' => '集計を行いたいデータ',
91
- 'd2' => '(optional)集計を行いたいデータ',
92
- 'd3' => '(以降、同様に最大10個まで追加可能)'
90
+ '任意のキー' => '集計を行いたいデータ',
91
+ '任意のキー' => '(optional)集計を行いたいデータ',
92
+ '任意のキー' => '(以降、同様に最大10個まで追加可能)'
93
93
  )
94
94
  );
95
95
  $logger->post("grassland.data", $param);
96
+ ```
97
+
98
+ ptを省略した場合、fluentdが受け付けた時間のUTC時刻として入力されます。
99
+ 「任意のキー」は、グラフに表示される一つの要素になります。
100
+ 例を以下に示します。
101
+
102
+ ```
103
+ //timezone設定
104
+ date_default_timezone_set('Asia/Tokyo');
105
+
106
+ $param = array(
107
+ 'cid' => 'cid0000001',
108
+ 'dt' => 'd822fab12eeb4db997db87876a082d82',
109
+ 'uid' => 'user001',
110
+ 'pt' => date( DATE_ISO8601, time() ),
111
+ 'd' => array(
112
+ 'item1' => '100',
113
+ 'item2' => '200'
114
+ )
115
+ );
116
+ $logger->post("grassland.data", $param);
96
117
  ```
@@ -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.2'
7
+ spec.version = '0.0.3'
8
8
  spec.authors = ['Ripplation Inc.']
9
9
  # spec.email = ['xxxxxx@ripplation.co.jp']
10
10
  spec.description = 'Output filter plugin for Grassland'
@@ -100,30 +100,34 @@ module Fluent
100
100
  putBuf = ""
101
101
  bufList = {}
102
102
 
103
- dataList.each do |data|
104
- if bufList[":#{data['pk']}"] == nil then
105
- bufList[":#{data['pk']}"] = "#{data.to_json},"
106
- else
107
- bufList[":#{data['pk']}"] += "#{data.to_json},"
108
- end
109
- if bufList[":#{data['pk']}"].bytesize >= 30720 then
110
- AWS.kinesis.client.put_record({
111
- :stream_name => @stream_name,
112
- :data => "["+bufList[":#{data['pk']}"].chop+"]",
113
- :partition_key => data['pk']
114
- })
115
- bufList.delete(":#{data['pk']}")
103
+ begin
104
+ dataList.each do |data|
105
+ if bufList[":#{data['pk']}"] == nil then
106
+ bufList[":#{data['pk']}"] = "#{data.to_json},"
107
+ else
108
+ bufList[":#{data['pk']}"] += "#{data.to_json},"
109
+ end
110
+ if bufList[":#{data['pk']}"].bytesize >= 30720 then
111
+ AWS.kinesis.client.put_record({
112
+ :stream_name => @stream_name,
113
+ :data => "["+bufList[":#{data['pk']}"].chop+"]",
114
+ :partition_key => data['pk']
115
+ })
116
+ bufList.delete(":#{data['pk']}")
117
+ end
116
118
  end
117
- end
118
- dataList.each do |data|
119
- if bufList[":#{data['pk']}"] != nil then
120
- AWS.kinesis.client.put_record({
121
- :stream_name => @stream_name,
122
- :data => "["+bufList[":#{data['pk']}"].chop+"]",
123
- :partition_key => data['pk']
124
- })
125
- bufList.delete(":#{data['pk']}")
119
+ dataList.each do |data|
120
+ if bufList[":#{data['pk']}"] != nil then
121
+ AWS.kinesis.client.put_record({
122
+ :stream_name => @stream_name,
123
+ :data => "["+bufList[":#{data['pk']}"].chop+"]",
124
+ :partition_key => data['pk']
125
+ })
126
+ bufList.delete(":#{data['pk']}")
127
+ end
126
128
  end
129
+ rescue
130
+ puts "error: put_record to grassland. maybe too many requests. few data dropped."
127
131
  end
128
132
  end
129
133
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-grassland
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ripplation Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd