logstash-output-thinkingdata 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/logstash/outputs/thinkingdata.rb +53 -26
- data/logstash-output-thinkingdata.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e867be173142072e9d2355704097e7440cbc159c2a1a7de39f8dc97e6d2e60df
|
4
|
+
data.tar.gz: 92bd1a49b9f661d64370b2ba2e1fdbb6005e98dfa66850feb649113582a1f687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eae1bf5a3dc7e72d02610ff020d3541df9a64a39504699f6dba1e4e61e0de429c45b7322693cd88f8f0b5016e254a8e0452fb6ab4454b5529ea8597fd6de3dd4
|
7
|
+
data.tar.gz: 73ed46b15a675a0d2b8ae7f1dbb897cb05147a7ac12a72552f944ffd366bc820b5c01ed75e5238056e9fff70bd9caec2deb728dab846e57b467070545d0698ce
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,6 @@ require "stud/buffer"
|
|
6
6
|
require "zlib"
|
7
7
|
require "json"
|
8
8
|
|
9
|
-
|
10
9
|
# An thinkingdata output that does nothing.
|
11
10
|
class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
12
11
|
|
@@ -42,7 +41,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
42
41
|
# 是否检测appid
|
43
42
|
config :appid_check, :validate => :boolean, :default => false
|
44
43
|
|
45
|
-
PLUGIN_VERSION = "1.
|
44
|
+
PLUGIN_VERSION = "1.2.1"
|
46
45
|
|
47
46
|
public
|
48
47
|
|
@@ -67,9 +66,9 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
67
66
|
@last_report_count = 0
|
68
67
|
@total_send_count = 0
|
69
68
|
buffer_config = {
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
:max_items => @flush_batch_size.to_i,
|
70
|
+
:max_interval => @flush_interval_sec.to_i,
|
71
|
+
:logger => @logger
|
73
72
|
}
|
74
73
|
buffer_initialize(buffer_config)
|
75
74
|
@filebeat_status = {} if @is_filebeat_status_record
|
@@ -83,7 +82,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
83
82
|
|
84
83
|
# def register
|
85
84
|
|
86
|
-
|
85
|
+
# 验证appid
|
87
86
|
|
88
87
|
private
|
89
88
|
|
@@ -99,6 +98,25 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
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
|
107
|
+
content['#uuid'] = SecureRandom.uuid if @uuid
|
108
|
+
if is_filebeat_input?(event) # filebeat input 记录
|
109
|
+
host = event.get("[host][name]")
|
110
|
+
file = event.get("[log][file][path]")
|
111
|
+
file = event.get("[source]") if file.nil?
|
112
|
+
offset = event.get("[log][offset]")
|
113
|
+
offset = event.get("[offset]") if offset.nil?
|
114
|
+
log_detail = "host: #{host}, file: #{file}"
|
115
|
+
record_filebeat_status(log_detail, offset) if @is_filebeat_status_record
|
116
|
+
end
|
117
|
+
buffer_receive(content)
|
118
|
+
end
|
119
|
+
|
102
120
|
public
|
103
121
|
|
104
122
|
def multi_receive(events)
|
@@ -106,18 +124,22 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
106
124
|
@receive_count += events.length
|
107
125
|
events.each do |event|
|
108
126
|
begin
|
109
|
-
|
110
|
-
|
111
|
-
if
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
127
|
+
message = event.get("message")
|
128
|
+
# 判断 message 中的数据是否为json array
|
129
|
+
if message[0, 1] == "["
|
130
|
+
contents = JSON.parse(message)
|
131
|
+
contents.each do |content|
|
132
|
+
begin
|
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
|
137
|
+
end
|
138
|
+
end
|
139
|
+
else
|
140
|
+
content = JSON.parse(message)
|
141
|
+
send_content(content, event)
|
119
142
|
end
|
120
|
-
buffer_receive(content)
|
121
143
|
rescue => e
|
122
144
|
@logger.error("Could not process content", :content => event.to_s, :Exception => e)
|
123
145
|
@parse_error_count += 1
|
@@ -154,16 +176,16 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
154
176
|
compress_type = 'gzip'
|
155
177
|
end
|
156
178
|
if @appid.nil? || @appid.empty?
|
157
|
-
headers = {'custom_appid' => 'true', 'version' => PLUGIN_VERSION, 'user-agent' => 'logstash_' + PLUGIN_VERSION,
|
158
|
-
|
159
|
-
|
179
|
+
headers = { 'custom_appid' => 'true', 'version' => PLUGIN_VERSION, 'user-agent' => 'logstash_' + PLUGIN_VERSION,
|
180
|
+
'compress' => compress_type, 'TA-Integration-Type' => 'logstash',
|
181
|
+
'TA-Integration-Version' => PLUGIN_VERSION, 'TA-Integration-Count' => events.length.to_s }
|
160
182
|
else
|
161
|
-
headers = {'appid' => @appid, 'version' => PLUGIN_VERSION, 'user-agent' => 'logstash_' + PLUGIN_VERSION,
|
162
|
-
|
163
|
-
|
183
|
+
headers = { 'appid' => @appid, 'version' => PLUGIN_VERSION, 'user-agent' => 'logstash_' + PLUGIN_VERSION,
|
184
|
+
'compress' => compress_type, 'TA-Integration-Type' => 'logstash',
|
185
|
+
'TA-Integration-Version' => PLUGIN_VERSION, 'TA-Integration-Count' => events.length.to_s }
|
164
186
|
end
|
165
187
|
|
166
|
-
until do_send(data, headers)
|
188
|
+
until do_send(data, events, headers)
|
167
189
|
sleep 5
|
168
190
|
end
|
169
191
|
@total_send_count += events.length
|
@@ -171,12 +193,17 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
171
193
|
|
172
194
|
private
|
173
195
|
|
174
|
-
def do_send(data, headers)
|
196
|
+
def do_send(data, events, headers)
|
175
197
|
begin
|
176
198
|
response = @client.post(@url, :body => data, :headers => headers).call
|
177
199
|
if response.code != 200
|
178
200
|
@logger.error("Send failed, code: #{response.code}, body: #{response.body}", :url => @url)
|
179
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
|
180
207
|
end
|
181
208
|
rescue => e
|
182
209
|
@logger.error("Send failed", :url => @url, :exception => e.class.name, :backtrace => e.backtrace)
|
@@ -202,7 +229,7 @@ class LogStash::Outputs::Thinkingdata < LogStash::Outputs::Base
|
|
202
229
|
def record_filebeat_status(log_detail, offset)
|
203
230
|
status = @filebeat_status[log_detail]
|
204
231
|
if status.nil?
|
205
|
-
status = {:receive_time => Time.now, :offset => offset}
|
232
|
+
status = { :receive_time => Time.now, :offset => offset }
|
206
233
|
@filebeat_status[log_detail] = status
|
207
234
|
else
|
208
235
|
status[:offset] = offset
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-thinkingdata'
|
3
|
-
s.version = '1.
|
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.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sdk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
@@ -144,7 +144,7 @@ licenses:
|
|
144
144
|
metadata:
|
145
145
|
logstash_plugin: 'true'
|
146
146
|
logstash_group: output
|
147
|
-
post_install_message:
|
147
|
+
post_install_message:
|
148
148
|
rdoc_options: []
|
149
149
|
require_paths:
|
150
150
|
- lib
|
@@ -159,8 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.0.
|
163
|
-
signing_key:
|
162
|
+
rubygems_version: 3.0.3.1
|
163
|
+
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Output plugin for Thinkingdata Analytics
|
166
166
|
test_files:
|