logstash-output-thinkingdata 1.2.0 → 1.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: a59cb189b3b65b95a23f1c54039948220adc9701d61425441c21e6ae13f0a207
4
- data.tar.gz: bffcdc6a7f831a884cef5dfb94d9da423f356c86994fa9e17da2350d7a552002
3
+ metadata.gz: e867be173142072e9d2355704097e7440cbc159c2a1a7de39f8dc97e6d2e60df
4
+ data.tar.gz: 92bd1a49b9f661d64370b2ba2e1fdbb6005e98dfa66850feb649113582a1f687
5
5
  SHA512:
6
- metadata.gz: '048904134164411ec9b61e60719a264b43c2d4dc7faa4220eb47a88d52077090b6c4ca5b0259cba32c3707d1bc67564bedd3aeb82ed84ddd9dbdea5a1e042956'
7
- data.tar.gz: 7f7ff7da269b11ac1ce317c3562ac8371bb92a92d6338c9a13a55902a9112e05f6f3d5b90d5a561bcc894021f327762ee88340c6b102f799c149864403a3e87a
6
+ metadata.gz: eae1bf5a3dc7e72d02610ff020d3541df9a64a39504699f6dba1e4e61e0de429c45b7322693cd88f8f0b5016e254a8e0452fb6ab4454b5529ea8597fd6de3dd4
7
+ data.tar.gz: 73ed46b15a675a0d2b8ae7f1dbb897cb05147a7ac12a72552f944ffd366bc820b5c01ed75e5238056e9fff70bd9caec2deb728dab846e57b467070545d0698ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ **v1.2.1** (2023-07-26)
2
+ - 增加对message中的数据进行格式校验
3
+
1
4
  **v1.2.0** (2023-04-25)
2
5
  - 支持message中传多条数据
3
6
 
@@ -41,7 +41,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
41
41
  # 是否检测appid
42
42
  config :appid_check, :validate => :boolean, :default => false
43
43
 
44
- PLUGIN_VERSION = "1.2.0"
44
+ PLUGIN_VERSION = "1.2.1"
45
45
 
46
46
  public
47
47
 
@@ -82,7 +82,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
82
82
 
83
83
  # def register
84
84
 
85
- #验证appid
85
+ # 验证appid
86
86
 
87
87
  private
88
88
 
@@ -99,8 +99,13 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
99
99
  end
100
100
 
101
101
  def send_content(content, event)
102
+ if content.to_s[0, 1] != '{'
103
+ @logger.error("data error: " + content.to_s)
104
+ @parse_error_count += 1
105
+ return
106
+ end
102
107
  content['#uuid'] = SecureRandom.uuid if @uuid
103
- if is_filebeat_input?(event) #filebeat input 记录
108
+ if is_filebeat_input?(event) # filebeat input 记录
104
109
  host = event.get("[host][name]")
105
110
  file = event.get("[log][file][path]")
106
111
  file = event.get("[source]") if file.nil?
@@ -126,13 +131,15 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
126
131
  contents.each do |content|
127
132
  begin
128
133
  send_content(content, event)
134
+ rescue => e
135
+ @logger.error("Could not process content", :content => event.to_s, :Exception => e)
136
+ @parse_error_count += 1
129
137
  end
130
138
  end
131
139
  else
132
140
  content = JSON.parse(message)
133
141
  send_content(content, event)
134
142
  end
135
-
136
143
  rescue => e
137
144
  @logger.error("Could not process content", :content => event.to_s, :Exception => e)
138
145
  @parse_error_count += 1
@@ -178,7 +185,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
178
185
  'TA-Integration-Version' => PLUGIN_VERSION, 'TA-Integration-Count' => events.length.to_s }
179
186
  end
180
187
 
181
- until do_send(data, headers)
188
+ until do_send(data, events, headers)
182
189
  sleep 5
183
190
  end
184
191
  @total_send_count += events.length
@@ -186,12 +193,17 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
186
193
 
187
194
  private
188
195
 
189
- def do_send(data, headers)
196
+ def do_send(data, events, headers)
190
197
  begin
191
198
  response = @client.post(@url, :body => data, :headers => headers).call
192
199
  if response.code != 200
193
200
  @logger.error("Send failed, code: #{response.code}, body: #{response.body}", :url => @url)
194
201
  return false
202
+ else
203
+ response_body = JSON.parse(response.body)
204
+ if response_body["code"] != 0
205
+ @logger.error("Send failed, code: #{response.code}, body: #{response.body}, request data: #{events.to_s}", :url => @url)
206
+ end
195
207
  end
196
208
  rescue => e
197
209
  @logger.error("Send failed", :url => @url, :exception => e.class.name, :backtrace => e.backtrace)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-thinkingdata'
3
- s.version = '1.2.0'
3
+ s.version = '1.2.1'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Output plugin for Thinkingdata Analytics'
6
6
  s.description = 'This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-thinkingdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sdk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api