logstash-output-treasure_data 0.9.2 → 1.0.0.pre1
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/treasure_data.rb +17 -20
- data/logstash-output-treasure_data.gemspec +4 -5
- metadata +29 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c3ff3748f4a47764ad43b4dca3f864f1b50f93b
|
4
|
+
data.tar.gz: 6bd09e966b142576773092f4d301598c5da15404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82344fc02835f4a311dc33b39b7a837d3e0add9c3f1a8ad2e826013c44ff6274e6427f89b4901aeaa3df2d1ff8bd694ae186602a642d48b491a3293ba40f94e7
|
7
|
+
data.tar.gz: c13901a2a622a6d9cd8908f1113a03f8ef0210c4b73679f8106c6a9d7b4a3289d0b370f79755bcbe617c1e1967489fbd3413da21c94cd60737a975760f2a4193
|
@@ -6,27 +6,18 @@ require "stud/buffer"
|
|
6
6
|
|
7
7
|
require "td-client"
|
8
8
|
require "msgpack"
|
9
|
-
require "uuid"
|
10
9
|
|
10
|
+
require "securerandom"
|
11
11
|
require "stringio"
|
12
12
|
require "zlib"
|
13
13
|
|
14
14
|
# Logstash output plugin to send data to Treasure Data service.
|
15
15
|
|
16
|
-
class LogStash::Event
|
17
|
-
def to_msgpack(packer=nil)
|
18
|
-
# LogStash objects (ex: LogStash::Timestamp) are impossible to serialize by msgpack
|
19
|
-
begin
|
20
|
-
@data.reject{|a,b| a == TIMESTAMP }.to_msgpack
|
21
|
-
rescue ArgumentError, NoMethodError
|
22
|
-
LogStash::Json.load(LogStash::Json.dump(@data)).to_msgpack
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
16
|
class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
28
17
|
include Stud::Buffer
|
29
18
|
|
19
|
+
concurrency :shared if self.respond_to?(:concurrency)
|
20
|
+
|
30
21
|
config_name "treasure_data"
|
31
22
|
|
32
23
|
IMPORT_SIZE_LIMIT = 32 * 1024 * 1024
|
@@ -58,12 +49,11 @@ class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
|
58
49
|
def register
|
59
50
|
@empty_gz_data = TreasureData::API.create_empty_gz_data
|
60
51
|
@user_agent = "logstash-output-treasure_data: #{VERSION}".freeze
|
61
|
-
@uuid = UUID.new
|
62
52
|
|
63
53
|
TreasureData::API.validate_database_name(@database)
|
64
54
|
TreasureData::API.validate_table_name(@table)
|
65
55
|
|
66
|
-
client_opts = {
|
56
|
+
@client_opts = {
|
67
57
|
ssl: @use_ssl,
|
68
58
|
http_proxy: @http_proxy,
|
69
59
|
user_agent: @user_agent,
|
@@ -72,7 +62,6 @@ class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
|
72
62
|
read_timeout: @read_timeout,
|
73
63
|
send_timeout: @send_timeout
|
74
64
|
}
|
75
|
-
@client = TreasureData::Client.new(@apikey.value, client_opts)
|
76
65
|
|
77
66
|
buffer_initialize(
|
78
67
|
max_items: @flush_size,
|
@@ -83,15 +72,16 @@ class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
|
83
72
|
|
84
73
|
public
|
85
74
|
def receive(event)
|
75
|
+
# Logstash::Output::Base#multi_receive(events) calls this method by `events.each{|event| receive(event) }`
|
86
76
|
record = event.clone
|
87
77
|
@logger.debug "receive a event"
|
88
78
|
|
89
|
-
record
|
79
|
+
record.set('time', record.timestamp.to_i || Time.now.to_i) unless record.get('time')
|
90
80
|
if record.to_hash.size > RECORD_KEYS_LIMIT
|
91
81
|
raise "Too many number of keys (#{record.keys.size} keys)"
|
92
82
|
end
|
93
83
|
|
94
|
-
row = record
|
84
|
+
row = convert_to_msgpack(record)
|
95
85
|
if row.bytesize > RECORD_SIZE_LIMIT
|
96
86
|
raise "Too large record (#{row.bytesize} bytes with keys:#{record.keys.join(',')})"
|
97
87
|
end
|
@@ -100,12 +90,18 @@ class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
|
100
90
|
@logger.debug "buffered a event"
|
101
91
|
end
|
102
92
|
|
93
|
+
def convert_to_msgpack(record)
|
94
|
+
record.to_hash.to_msgpack
|
95
|
+
rescue ArgumentError, NoMethodError
|
96
|
+
LogStash::Json.load(LogStash::Json.dump(record.to_hash)).to_msgpack
|
97
|
+
end
|
98
|
+
|
103
99
|
public
|
104
100
|
def flush(events, teardown = false)
|
105
101
|
@logger.debug "flushing #{events} events (may include chunk uuid)"
|
106
102
|
return if events.size < 1
|
107
103
|
if UUID_FORMAT !~ events.first
|
108
|
-
new_uuid =
|
104
|
+
new_uuid = SecureRandom.uuid
|
109
105
|
@logger.debug "adding chunk uuid #{new_uuid}"
|
110
106
|
events.unshift new_uuid
|
111
107
|
end
|
@@ -122,15 +118,16 @@ class LogStash::Outputs::TreasureData < LogStash::Outputs::Base
|
|
122
118
|
f.finish
|
123
119
|
}
|
124
120
|
data = io.string
|
121
|
+
client = TreasureData::Client.new(@apikey.value, @client_opts)
|
125
122
|
@logger.debug "sending gzipped chunk #{uuid}, #{data.bytesize} bytes"
|
126
123
|
begin
|
127
|
-
|
124
|
+
client.import(@database, @table, "msgpack.gz", data, data.bytesize, uuid)
|
128
125
|
|
129
126
|
rescue TreasureData::NotFoundError => e
|
130
127
|
raise unless @auto_create_table
|
131
128
|
|
132
129
|
@logger.info "creating missing table #{@table} on database #{@database} for chunk #{uuid}"
|
133
|
-
ensure_table_exists(
|
130
|
+
ensure_table_exists(client, @database, @table)
|
134
131
|
@logger.info "retrying upload chunk #{uuid}"
|
135
132
|
retry
|
136
133
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-treasure_data'
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "1.0.0.pre1"
|
4
4
|
s.licenses = ["Apache License (2.0)"]
|
5
5
|
s.summary = "Logstash plugin to store data into Treasure Data service."
|
6
6
|
s.description = "This gem is a logstash plugin to store data from logstash to Treasure Data service. This gem is not a stand-alone program."
|
@@ -18,10 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
19
19
|
|
20
20
|
# Gem dependencies
|
21
|
-
s.add_runtime_dependency "logstash-core", ">=
|
21
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
22
22
|
s.add_runtime_dependency "logstash-codec-plain"
|
23
|
-
s.add_runtime_dependency "msgpack", "~> 0
|
24
|
-
s.add_runtime_dependency "td-client", "~> 0
|
25
|
-
s.add_runtime_dependency "uuid", "~> 2.3"
|
23
|
+
s.add_runtime_dependency "msgpack", "~> 1.0"
|
24
|
+
s.add_runtime_dependency "td-client", "~> 1.0"
|
26
25
|
s.add_development_dependency "logstash-devutils"
|
27
26
|
end
|
metadata
CHANGED
@@ -1,107 +1,92 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-treasure_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Tagomori
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
18
|
+
version: '1.60'
|
19
|
+
- - "<="
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
|
21
|
+
version: '2.99'
|
22
|
+
name: logstash-core-plugin-api
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: '1.60'
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: '2.99'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-plain
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: '0'
|
40
|
-
|
39
|
+
name: logstash-codec-plain
|
41
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name: msgpack
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
50
|
- - "~>"
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0
|
54
|
-
|
52
|
+
version: '1.0'
|
53
|
+
name: msgpack
|
55
54
|
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 0.7.4
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: td-client
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 0.8.78
|
68
55
|
type: :runtime
|
69
|
-
prerelease: false
|
70
56
|
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
58
|
- - "~>"
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0
|
60
|
+
version: '1.0'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
|
-
name: uuid
|
77
62
|
requirement: !ruby/object:Gem::Requirement
|
78
63
|
requirements:
|
79
64
|
- - "~>"
|
80
65
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
82
|
-
|
66
|
+
version: '1.0'
|
67
|
+
name: td-client
|
83
68
|
prerelease: false
|
69
|
+
type: :runtime
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
72
|
- - "~>"
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
74
|
+
version: '1.0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: logstash-devutils
|
91
76
|
requirement: !ruby/object:Gem::Requirement
|
92
77
|
requirements:
|
93
78
|
- - ">="
|
94
79
|
- !ruby/object:Gem::Version
|
95
80
|
version: '0'
|
96
|
-
|
81
|
+
name: logstash-devutils
|
97
82
|
prerelease: false
|
83
|
+
type: :development
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
100
86
|
- - ">="
|
101
87
|
- !ruby/object:Gem::Version
|
102
88
|
version: '0'
|
103
|
-
description: This gem is a logstash plugin to store data from logstash to Treasure
|
104
|
-
Data service. This gem is not a stand-alone program.
|
89
|
+
description: This gem is a logstash plugin to store data from logstash to Treasure Data service. This gem is not a stand-alone program.
|
105
90
|
email: tagomoris@gmail.com
|
106
91
|
executables: []
|
107
92
|
extensions: []
|
@@ -123,7 +108,7 @@ licenses:
|
|
123
108
|
metadata:
|
124
109
|
logstash_plugin: 'true'
|
125
110
|
logstash_group: output
|
126
|
-
post_install_message:
|
111
|
+
post_install_message:
|
127
112
|
rdoc_options: []
|
128
113
|
require_paths:
|
129
114
|
- lib
|
@@ -134,15 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
119
|
version: '0'
|
135
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
121
|
requirements:
|
137
|
-
- - "
|
122
|
+
- - ">"
|
138
123
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
124
|
+
version: 1.3.1
|
140
125
|
requirements: []
|
141
|
-
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
143
|
-
signing_key:
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.4.8
|
128
|
+
signing_key:
|
144
129
|
specification_version: 4
|
145
130
|
summary: Logstash plugin to store data into Treasure Data service.
|
146
131
|
test_files:
|
147
132
|
- spec/outputs/treasure_data_spec.rb
|
148
|
-
has_rdoc:
|