logstash-output-logservice 0.14.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/outputs/logservice.rb +46 -100
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/aliyun-log-producer-0.3.24-jar-with-dependencies.jar +0 -0
- data/logstash-output-logservice.gemspec +1 -1
- metadata +4 -11
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/aliyun-log-private-cloud-0.6.73.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/commons-codec-1.9.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/commons-logging-1.2.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/gson-2.9.0.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/httpclient-4.5.1.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/httpcore-4.4.3.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/lz4-1.3.0.jar +0 -0
- data/lib/logstash/vendor/jar-dependencies/runtime-jars/protobuf-java-2.5.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d7ee23a182065c1c6aa30fc0006f12e3402507524d1f4cd6fac8bb7cf7e68a1
|
4
|
+
data.tar.gz: e6675c6ee323e7052c5b2112373e354f36aa48699601982d02dc6cb46c6bb181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62d1e3d250b625aa5d342741bd16c65a9c31c142f21d89764d2ff6b399ff1b166fdb2fda05cfcc40ce3a10474b58cd685b1527789820b4794424b1830e4547fe
|
7
|
+
data.tar.gz: 3828ec71944858a6ae59b00680e0edb9423fcb11af78cd17ac7c4575aadb76f3e609d5457b30057c793f17887263b855ec9771d583ffd5750b189add795fe294
|
@@ -7,10 +7,7 @@ require 'socket'
|
|
7
7
|
require "java"
|
8
8
|
require 'json'
|
9
9
|
|
10
|
-
import "java.util.ArrayList"
|
11
|
-
|
12
10
|
root_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
13
|
-
|
14
11
|
LogStash::Environment.load_runtime_jars! File.join(root_dir, "vendor")
|
15
12
|
|
16
13
|
class LogStash::Outputs::LogService < LogStash::Outputs::Base
|
@@ -31,134 +28,83 @@ class LogStash::Outputs::LogService < LogStash::Outputs::Base
|
|
31
28
|
config :access_key_secret, :validate=> :string, :required=> true
|
32
29
|
|
33
30
|
# default 4000 logs in a logGroup for batch send
|
34
|
-
config :max_buffer_items, :validate=> :number, :required=> false, :default=>
|
31
|
+
config :max_buffer_items, :validate=> :number, :required=> false, :default=> 4096
|
35
32
|
# default 2*1024*1024 Bytes in a logGroup for batch send
|
36
33
|
config :max_buffer_bytes, :validate=> :number, :required=> false, :default=> 2097152
|
37
34
|
# for batch send, logGroup will emit in default 3 seconds
|
38
35
|
config :max_buffer_seconds, :validate=> :number, :required=> false, :default=> 3
|
36
|
+
# the maximum log size that a single producer instance can cache is 100MB by default.
|
37
|
+
config :total_size_in_bytes, :validate=> :number, :required=> false, :default=> 104857600
|
39
38
|
|
40
39
|
# logGroup will retry send to log service when error happened, and will be discard when retry times exceed limit
|
41
|
-
config :max_send_retry, :validate=> :number, :required=> true, :default=> 10
|
40
|
+
config :max_send_retry, :validate=> :number, :required=> true, :default=> 10
|
42
41
|
# sleep default 200 milliseconds before retry next send
|
43
42
|
config :send_retry_interval, :validate=> :number, :required=> false, :default=> 200
|
44
43
|
|
45
44
|
config :to_json, :validate=> :boolean, :required=> false, :default=> true
|
46
45
|
config :time_key, :validate=> :string, :required=> false, :default=> "@timestamp"
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
LP = com.aliyun.openservices.aliyun.log.producer
|
48
|
+
LogCommon = com.shade.aliyun.openservices.log.common
|
49
|
+
|
51
50
|
|
52
51
|
public
|
53
52
|
def register
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
)
|
59
|
-
@
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
@producerConfig = LP.ProducerConfig::new();
|
54
|
+
@producerConfig.setBatchCountThreshold(@max_buffer_items);
|
55
|
+
@producerConfig.setBatchSizeThresholdInBytes(@max_buffer_bytes);
|
56
|
+
@producerConfig.setLingerMs(@max_buffer_seconds*1000);
|
57
|
+
@producerConfig.setRetries(@max_send_retry);
|
58
|
+
@producerConfig.setBaseRetryBackoffMs(@send_retry_interval);
|
59
|
+
@producerConfig.setTotalSizeInBytes(@total_size_in_bytes);
|
60
|
+
@producer = LP.LogProducer::new(@producerConfig);
|
61
|
+
@producer.putProjectConfig(LP.ProjectConfig::new(@project, @endpoint, @access_key_id, @access_key_secret));
|
62
|
+
|
64
63
|
@logger.info("init logstash-output-logservice plugin", :endpoint => @endpoint, :project => @project, :logstore => @logstore, :topic => @topic, :source => @source, :max_buffer_bytes => @max_buffer_bytes)
|
65
64
|
end # def register
|
66
65
|
|
67
66
|
public
|
68
67
|
def receive(event)
|
69
|
-
return unless output?(event)
|
70
68
|
begin
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
end # def event
|
76
|
-
|
77
|
-
def send_to_log_service(loggroup)
|
78
|
-
@retry = 0
|
79
|
-
begin
|
80
|
-
@retry += 1
|
81
|
-
@logclient.PutLogs(@project, @logstore, @topic, loggroup, @source.to_s)
|
82
|
-
@logger.info("send logs to logservice success", :logcount => loggroup.size().to_s)
|
83
|
-
rescue LogException => e
|
84
|
-
@error_code = e.GetErrorCode()
|
85
|
-
@error_message = e.GetErrorMessage()
|
86
|
-
if @retry < @max_send_retry
|
87
|
-
@logger.warn("send logs to logservice fail, will retry later", :exception => e, :error_code => @error_code, :error_message => @error_message, :retry => @retry)
|
88
|
-
sleep(@send_retry_interval_seconds)
|
89
|
-
retry
|
90
|
-
else
|
91
|
-
@logger.error("send logs to logservice fail, discard data", :exception => e, :error_code => @error_code, :error_message => @error_message, :retry => @retry)
|
69
|
+
@event_map = event.to_hash
|
70
|
+
if @event_map.size < 1
|
71
|
+
return
|
92
72
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
@logger.error("send logs to logservice fail, discard data", :exception => e, :retry => @retry)
|
73
|
+
@logitem = LogCommon.LogItem.new
|
74
|
+
#@timestamp like 2016-02-18T03:23:11.053Z
|
75
|
+
time_value = @event_map[@time_key]
|
76
|
+
if time_value.nil?
|
77
|
+
time_value = @event_map['@timestamp']
|
78
|
+
@logger.warn("The time_key is nil, use @timestamp")
|
100
79
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
@loggroup = ArrayList.new
|
111
|
-
@byte_size = 0
|
112
|
-
events.each { |x|
|
113
|
-
begin
|
114
|
-
@event_map = x.to_hash
|
115
|
-
if @event_map.size < 1
|
80
|
+
time_s = Time.parse(time_value.to_s)
|
81
|
+
@logitem.SetTime(time_s.to_i)
|
82
|
+
time_ms_part=time_s.to_datetime().strftime('%L').to_i
|
83
|
+
@logitem.SetTimeNsPart(time_ms_part*1000000)
|
84
|
+
@event_map.each do | key, value |
|
85
|
+
@key_str = key.to_s
|
86
|
+
if @key_str == '__time__'
|
116
87
|
next
|
117
88
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
time_value = @event_map['@timestamp']
|
123
|
-
@logger.warn("The time_key is nil, use @timestamp")
|
124
|
-
end
|
125
|
-
@logitem.SetTime(Time.parse(time_value.to_s).to_i)
|
126
|
-
@event_map.each do | key, value |
|
127
|
-
@key_str = key.to_s
|
128
|
-
if @key_str == '__time__'
|
129
|
-
next
|
130
|
-
end
|
131
|
-
if value.instance_of? Hash
|
132
|
-
@value_str = value.to_json
|
133
|
-
else
|
134
|
-
@value_str = value.to_s
|
135
|
-
end
|
136
|
-
# if @to_json
|
137
|
-
# @value_str = value.to_json
|
138
|
-
# else
|
139
|
-
# @value_str = value.to_s
|
140
|
-
# end
|
141
|
-
@byte_size += @key_str.length + @value_str.length
|
142
|
-
@logitem.PushBack(@key_str, @value_str)
|
143
|
-
end
|
144
|
-
@loggroup.add(@logitem)
|
145
|
-
if @byte_size > @max_buffer_bytes
|
146
|
-
send_to_log_service(@loggroup)
|
147
|
-
@loggroup = ArrayList.new
|
148
|
-
@byte_size = 0
|
89
|
+
if value.instance_of? Hash
|
90
|
+
@value_str = value.to_json
|
91
|
+
else
|
92
|
+
@value_str = value.to_s
|
149
93
|
end
|
94
|
+
@logitem.PushBack(@key_str, @value_str)
|
95
|
+
end
|
96
|
+
@producer.send(@project, @logstore, @topic, @source, @logitem)
|
150
97
|
rescue => e
|
151
|
-
@logger.warn("
|
98
|
+
@logger.warn("send log data fail", :exception => e)
|
152
99
|
end
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
100
|
+
end # def event
|
101
|
+
|
102
|
+
def flush(events, close=false)
|
157
103
|
end
|
158
104
|
|
159
105
|
public
|
160
106
|
def close
|
161
|
-
|
107
|
+
@producer.close();
|
162
108
|
end # def close
|
163
109
|
|
164
|
-
end # class LogStash::Outputs::LogService
|
110
|
+
end # class LogStash::Outputs::LogService
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-logservice'
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.16.0"
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = "post data into logservice."
|
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/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-logservice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tangkai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core-plugin-api
|
@@ -84,14 +84,7 @@ files:
|
|
84
84
|
- LICENSE
|
85
85
|
- README.md
|
86
86
|
- lib/logstash/outputs/logservice.rb
|
87
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/aliyun-log-
|
88
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/commons-codec-1.9.jar
|
89
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/commons-logging-1.2.jar
|
90
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/gson-2.9.0.jar
|
91
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/httpclient-4.5.1.jar
|
92
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/httpcore-4.4.3.jar
|
93
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/lz4-1.3.0.jar
|
94
|
-
- lib/logstash/vendor/jar-dependencies/runtime-jars/protobuf-java-2.5.0.jar
|
87
|
+
- lib/logstash/vendor/jar-dependencies/runtime-jars/aliyun-log-producer-0.3.24-jar-with-dependencies.jar
|
95
88
|
- logstash-output-logservice.gemspec
|
96
89
|
- spec/outputs/logservice_spec.rb
|
97
90
|
homepage: https://www.aliyun.com/product/sls
|
@@ -115,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
108
|
- !ruby/object:Gem::Version
|
116
109
|
version: '0'
|
117
110
|
requirements: []
|
118
|
-
rubygems_version: 3.0.3
|
111
|
+
rubygems_version: 3.0.3.1
|
119
112
|
signing_key:
|
120
113
|
specification_version: 4
|
121
114
|
summary: post data into logservice.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|