logstash-output-google_bigquery 2.0.3 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/LICENSE +1 -1
- data/README.md +12 -3
- data/lib/logstash/outputs/google_bigquery.rb +36 -13
- data/logstash-output-google_bigquery.gemspec +4 -4
- metadata +17 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a141fe1a35f5b762787fc94ba8e33b80af5fee
|
4
|
+
data.tar.gz: 22c6ada4627fd4c6d8f6c02f2e1830e823caf6f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c53eb5b412d72b15a3d0195f03a1e5f27d99ff12a2004fe472f33f1c0ea3fd3996e3507e1b04eefe200d2c5d55a2048363ae69a936b19290784aba51527e033
|
7
|
+
data.tar.gz: ae98407e1aa2807796f374b6b0ec50ba073570ad35367085a5984242fefe0aad40745adaab803ac5bd1ef3fa4a5b33b4ef2df07c2f92fc1d6761fea7ff503ab0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 2.0.6
|
2
|
+
- Pin version of gems whose latest releases only work with ruby 2.x
|
3
|
+
|
4
|
+
# 2.0.5
|
5
|
+
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
6
|
+
# 2.0.4
|
7
|
+
- New dependency requirements for logstash-core for the 5.0 release
|
1
8
|
## 2.0.3
|
2
9
|
- Add support for specifying schema as a hash
|
3
10
|
- Bubble up error message that BQ returns on an error
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[![Build
|
4
|
-
Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-google_bigquery-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-google_bigquery-unit/)
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-google_bigquery.svg)](https://travis-ci.org/logstash-plugins/logstash-output-google_bigquery)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
56
55
|
```
|
57
56
|
- Install plugin
|
58
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
59
62
|
bin/plugin install --no-verify
|
63
|
+
|
60
64
|
```
|
61
65
|
- Run Logstash with your plugin
|
62
66
|
```sh
|
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
74
78
|
```
|
75
79
|
- Install the plugin from the Logstash home
|
76
80
|
```sh
|
77
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
78
87
|
```
|
79
88
|
- Start Logstash and proceed to test the plugin
|
80
89
|
|
@@ -96,9 +96,13 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
96
96
|
config :dataset, :validate => :string, :required => true
|
97
97
|
|
98
98
|
# BigQuery table ID prefix to be used when creating new tables for log data.
|
99
|
-
# Table name will be <table_prefix
|
99
|
+
# Table name will be <table_prefix><table_separator><date>
|
100
100
|
config :table_prefix, :validate => :string, :default => "logstash"
|
101
101
|
|
102
|
+
# BigQuery table separator to be added between the table_prefix and the
|
103
|
+
# date suffix.
|
104
|
+
config :table_separator, :validate => :string, :default => "_"
|
105
|
+
|
102
106
|
# Schema for log data. It must follow this format:
|
103
107
|
# <field1-name>:<field1-type>,<field2-name>:<field2-type>,...
|
104
108
|
# Example: path:STRING,status:INTEGER,score:FLOAT
|
@@ -292,12 +296,20 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
292
296
|
def initialize_deleter
|
293
297
|
@uploader = Thread.new do
|
294
298
|
@logger.debug("BQ: starting deleter")
|
299
|
+
Dir.glob(get_undated_path() + "*.bqjob").each do |fn|
|
300
|
+
job_id = File.open(fn, 'r') { |f| f.read }
|
301
|
+
filename = @temp_directory + File::SEPARATOR + File.basename(fn, ".bqjob")
|
302
|
+
@logger.debug("BQ: resuming job.",
|
303
|
+
:job_id => job_id,
|
304
|
+
:filename => filename)
|
305
|
+
@delete_queue << { "filename" => filename, "job_id" => job_id }
|
306
|
+
end
|
295
307
|
while true
|
296
308
|
delete_item = @delete_queue.pop
|
297
309
|
job_id = delete_item["job_id"]
|
298
310
|
filename = delete_item["filename"]
|
299
311
|
job_status = get_job_status(job_id)
|
300
|
-
case job_status["state"]
|
312
|
+
case job_status["status"]["state"]
|
301
313
|
when "DONE"
|
302
314
|
if job_status.has_key?("errorResult")
|
303
315
|
@logger.error("BQ: job failed, please enable debug and check full "\
|
@@ -311,7 +323,8 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
311
323
|
:job_id => job_id,
|
312
324
|
:filename => filename,
|
313
325
|
:job_status => job_status)
|
314
|
-
File.delete(filename)
|
326
|
+
File.delete(filename) if File.exist?(filename)
|
327
|
+
File.delete(filename + ".bqjob") if File.exist?(filename + ".bqjob")
|
315
328
|
end
|
316
329
|
when "PENDING", "RUNNING"
|
317
330
|
@logger.debug("BQ: job is not done, NOT deleting local file yet.",
|
@@ -320,12 +333,13 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
320
333
|
:job_status => job_status)
|
321
334
|
@delete_queue << delete_item
|
322
335
|
else
|
323
|
-
@logger.error("BQ: unknown job status,
|
324
|
-
"check full response (probably the issue is an "\
|
325
|
-
"incompatible schema). NOT deleting local file yet.",
|
336
|
+
@logger.error("BQ: unknown job status, NOT deleting local file yet.",
|
326
337
|
:job_id => job_id,
|
327
338
|
:filename => filename,
|
328
339
|
:job_status => job_status)
|
340
|
+
File.open(filename + ".err", 'w') do |file|
|
341
|
+
file.write(LogStash::Json.dump(job_status))
|
342
|
+
end
|
329
343
|
end
|
330
344
|
|
331
345
|
sleep @deleter_interval_secs
|
@@ -367,6 +381,7 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
367
381
|
if File.size(filename) > 0
|
368
382
|
job_id = upload_object(filename)
|
369
383
|
@delete_queue << { "filename" => filename, "job_id" => job_id }
|
384
|
+
File.open(filename + ".bqjob", 'w') { |file| file.write(job_id) }
|
370
385
|
else
|
371
386
|
@logger.debug("BQ: skipping empty file.")
|
372
387
|
@logger.debug("BQ: delete local temporary file ",
|
@@ -490,6 +505,12 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
490
505
|
@client.authorization = service_account.authorize
|
491
506
|
end
|
492
507
|
|
508
|
+
def raise_if_error(response)
|
509
|
+
if response.has_key?("error")
|
510
|
+
raise response["error"]["message"]
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
493
514
|
##
|
494
515
|
# Uploads a local file to the configured bucket.
|
495
516
|
def get_job_status(job_id)
|
@@ -505,13 +526,10 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
505
526
|
@logger.debug("BQ: successfully invoked API.",
|
506
527
|
:response => response)
|
507
528
|
|
508
|
-
|
509
|
-
raise response["error"]
|
510
|
-
end
|
529
|
+
raise_if_error(response)
|
511
530
|
|
512
531
|
# Successful invocation
|
513
|
-
|
514
|
-
return contents
|
532
|
+
return response
|
515
533
|
rescue => e
|
516
534
|
@logger.error("BQ: failed to check status", :exception => e)
|
517
535
|
# TODO(rdc): limit retries?
|
@@ -524,7 +542,7 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
524
542
|
# Uploads a local file to the configured bucket.
|
525
543
|
def upload_object(filename)
|
526
544
|
begin
|
527
|
-
table_id = @table_prefix +
|
545
|
+
table_id = @table_prefix + @table_separator + get_date_pattern(filename)
|
528
546
|
# BQ does not accept anything other than alphanumeric and _
|
529
547
|
# Ref: https://developers.google.com/bigquery/browser-tool-quickstart?hl=en
|
530
548
|
table_id.tr!(':-','_')
|
@@ -557,7 +575,12 @@ class LogStash::Outputs::GoogleBigQuery < LogStash::Outputs::Base
|
|
557
575
|
},
|
558
576
|
:media => media)
|
559
577
|
|
560
|
-
|
578
|
+
media.close()
|
579
|
+
response_body = LogStash::Json.load(insert_result.response.body)
|
580
|
+
|
581
|
+
raise_if_error(response_body)
|
582
|
+
|
583
|
+
job_id = response_body["jobReference"]["jobId"]
|
561
584
|
@logger.debug("BQ: multipart insert",
|
562
585
|
:job_id => job_id)
|
563
586
|
return job_id
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-google_bigquery'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.6'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Plugin to upload log events to Google BigQuery (BQ)"
|
7
|
-
s.description = "This gem is a
|
7
|
+
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"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
10
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core", "
|
24
|
-
s.add_runtime_dependency 'google-api-client'
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
|
24
|
+
s.add_runtime_dependency 'google-api-client', "~> 0.8.7" # version 0.9.x needs ruby 2.x
|
25
25
|
|
26
26
|
s.add_development_dependency 'logstash-devutils'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,53 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-google_bigquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- -
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 3.0.0
|
22
|
-
name: logstash-core
|
18
|
+
version: '1.0'
|
19
|
+
name: logstash-core-plugin-api
|
23
20
|
prerelease: false
|
24
21
|
type: :runtime
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0.beta2
|
30
|
-
- - <
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: '1.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
36
|
-
- -
|
30
|
+
- - "~>"
|
37
31
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
32
|
+
version: 0.8.7
|
39
33
|
name: google-api-client
|
40
34
|
prerelease: false
|
41
35
|
type: :runtime
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
|
-
- -
|
38
|
+
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: 0.8.7
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
requirement: !ruby/object:Gem::Requirement
|
49
43
|
requirements:
|
50
|
-
- -
|
44
|
+
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '0'
|
53
47
|
name: logstash-devutils
|
@@ -55,10 +49,10 @@ dependencies:
|
|
55
49
|
type: :development
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- -
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
|
-
description: This gem is a
|
55
|
+
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
|
62
56
|
email: info@elastic.co
|
63
57
|
executables: []
|
64
58
|
extensions: []
|
@@ -85,17 +79,17 @@ require_paths:
|
|
85
79
|
- lib
|
86
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
81
|
requirements:
|
88
|
-
- -
|
82
|
+
- - ">="
|
89
83
|
- !ruby/object:Gem::Version
|
90
84
|
version: '0'
|
91
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
|
-
- -
|
87
|
+
- - ">="
|
94
88
|
- !ruby/object:Gem::Version
|
95
89
|
version: '0'
|
96
90
|
requirements: []
|
97
91
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.4.
|
92
|
+
rubygems_version: 2.4.8
|
99
93
|
signing_key:
|
100
94
|
specification_version: 4
|
101
95
|
summary: Plugin to upload log events to Google BigQuery (BQ)
|