fluent-plugin-grassland 0.2.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a50827624e60eb0a7e3aa7ece74ccb3b4ee63800efe9d5b882fd07667f98c0
4
- data.tar.gz: 33dc0fcfe60b74de19c3fdcbca92362aff2bf0a9e4391bbb80a724b8d6685625
3
+ metadata.gz: 0a58e5705d031e2680d0e20166851d5837aea29de2e0f635700b1b42315849c0
4
+ data.tar.gz: 925f4f26f5d36c91d06a3f08eb0994a0992a1fb2548af1c5ebc7677c9a0d1cb0
5
5
  SHA512:
6
- metadata.gz: 4ec89f13aeae1939aba751a8e87b03851b7316bfbc772dfab2d6247602d61236c0eaec16eef3bd67f320aa9fc9772849cca6d6f0830b96032296847c6393fcec
7
- data.tar.gz: e7272781f77dfbaf0afa8d512e23ac56d8f8e05b0a9732a3ab0c5ad7223ed7af9eacbc763b3020370b30a653110122e3293c1a9b6fb8dcf65c223f11bf0355b5
6
+ metadata.gz: f376fe29cdc9881dd025c545d98532b05596143841dd28175d514e626d34fe4625569cf5fb68b6cb0bfe450da29a69978c42fca00ff2fbfb65131aeede340eff
7
+ data.tar.gz: 5e5484eaa1b00cd6d09dd025062e885f78760355946f8f3981f80bffa0491191153af97fff4660d230444cc12297e3b3e3660896bd6cd1c9897ead98928271ca
@@ -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.2.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'
@@ -1,6 +1,9 @@
1
- module Fluent
2
- class GrasslandOutput < Fluent::BufferedOutput
3
- Fluent::Plugin.register_output('grassland', self)
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
@@ -16,6 +19,10 @@ module Fluent
16
19
  require 'net/http'
17
20
  require 'uri'
18
21
  @random = Random.new
22
+
23
+ log = Syslog::Logger.new 'grasslandplugin'
24
+ log.info 'grassland initialize'
25
+ # puts "grassland initialize"
19
26
  end
20
27
 
21
28
  config_param :apiuri, :string, :default => 'https://grassland.biz/credentials'
@@ -60,14 +67,14 @@ module Fluent
60
67
  begin
61
68
  setCredential
62
69
  configure_aws
63
- @kinesis.client.put_record({
70
+ @kinesis.put_record({
64
71
  :stream_name => @stream_name,
65
72
  :data => "test",
66
73
  :partition_key => "#{random.rand(999)}"
67
74
  })
68
- puts "fluentd: reset credential"
75
+ log.info "grassland: reset credential"
69
76
  rescue => e
70
- puts [e.class, e].join(" : initialize error.")
77
+ log.info [e.class, e].join(" : initialize error.")
71
78
  end
72
79
  end
73
80
 
@@ -100,11 +107,11 @@ module Fluent
100
107
  warn "redirected to #{location}"
101
108
  get_json(location, limit - 1)
102
109
  else
103
- puts [uri.to_s, response.value].join(" : ")
110
+ log.info [uri.to_s, response.value].join(" : ")
104
111
  # handle error
105
112
  end
106
113
  rescue => e
107
- puts [uri.to_s, e.class, e].join(" : ")
114
+ log.info [uri.to_s, e.class, e].join(" : ")
108
115
  # handle error
109
116
  end
110
117
  end
@@ -113,7 +120,7 @@ module Fluent
113
120
  # print(record)
114
121
  ['dt', 'd'].each do |key|
115
122
  unless record.has_key?(key)
116
- puts "input data error: '#{key}' is required"
123
+ log.info "input data error: '#{key}' is required"
117
124
  return ""
118
125
  end
119
126
  end
@@ -139,13 +146,15 @@ module Fluent
139
146
 
140
147
  begin
141
148
  dataList.each do |data|
149
+ # debug log
150
+ # log.info data.to_json
142
151
  if bufList[":#{data['pk']}"] == nil then
143
152
  bufList[":#{data['pk']}"] = "#{data.to_json},"
144
153
  else
145
154
  bufList[":#{data['pk']}"] += "#{data.to_json},"
146
155
  end
147
156
  if bufList[":#{data['pk']}"].bytesize >= 30720 then
148
- @kinesis.client.put_record({
157
+ @kinesis.put_record({
149
158
  :stream_name => @stream_name,
150
159
  :data => "["+bufList[":#{data['pk']}"].chop+"]",
151
160
  :partition_key => partitionKeys[random.rand(partitionKeys.length)]
@@ -156,7 +165,7 @@ module Fluent
156
165
  end
157
166
  dataList.each do |data|
158
167
  if bufList[":#{data['pk']}"] != nil then
159
- @kinesis.client.put_record({
168
+ @kinesis.put_record({
160
169
  :stream_name => @stream_name,
161
170
  :data => "["+bufList[":#{data['pk']}"].chop+"]",
162
171
  :partition_key => partitionKeys[random.rand(partitionKeys.length)]
@@ -166,7 +175,7 @@ module Fluent
166
175
  end
167
176
  end
168
177
  rescue
169
- puts "error: put_record to grassland. maybe too many requests. few data dropped."
178
+ log.info "error: put_record to grassland. maybe too many requests. few data dropped."
170
179
  end
171
180
  end
172
181
 
@@ -188,8 +197,7 @@ module Fluent
188
197
  )
189
198
  end
190
199
 
191
- @kinesis = AWS::Kinesis::Client.new(options)
192
- # AWS.config(options)
200
+ @kinesis = Aws::Kinesis::Client.new(options)
193
201
  end
194
202
  end
195
- end
203
+ end
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.2.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: 2020-10-17 00:00:00.000000000 Z
11
+ date: 2020-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.1.2
103
+ rubygems_version: 3.0.3
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Output filter plugin for Grassland