fluent-plugin-bigquery 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caee66954ca996b43797e050825d5115dcd132f8
4
- data.tar.gz: 040afb42fa0fe48f61a90d11e9ea5684d170974c
3
+ metadata.gz: 0802b40a0e2792d20ca2e92f20cfe398d92aa5db
4
+ data.tar.gz: a210aa8139c2d82467979adac99f6396096ef6d7
5
5
  SHA512:
6
- metadata.gz: 15aed88d76491c467ff6e865381d1d78884d632f998c71569e53faadb1acf18d572e4459b55d4ff5a3e57121365cf1ec90c4c292726e492bcfdac6a52ab7f815
7
- data.tar.gz: a5ed1a27a117a6f54a2931741c2ffdf37b856e54074af94e2740e70ed361fa21f4790a20e926d675019d1280574497303825562be0b75097200b5e58dd49646c
6
+ metadata.gz: 865a4f9cd3de0d912678768a5a29d3795b62382de2949ac7fc220446d2aaedb2c62616056ad2d44901c64c2782d45c3e2f2f1bb78ca73174394d1b2954291e5f
7
+ data.tar.gz: 1bde3427c107b3ac396e808f4856daff92f9a50666d07567dfe1b3cdd0fd50a0ca550b1573368b1913cde125dfa4d874ed6aa96862014fdb2bd22e950ce78bbf
data/README.md CHANGED
@@ -9,14 +9,13 @@ Fluentd output plugin to load/insert data into Google BigQuery.
9
9
  * for data loading as batch jobs, for big amount of data
10
10
  * https://developers.google.com/bigquery/loading-data-into-bigquery
11
11
 
12
- Current version of this plugin supports Google API with Service Account Authentication, and does not support OAuth.
12
+ Current version of this plugin supports Google API with Service Account Authentication, but does not support
13
+ OAuth flow for installed applications.
13
14
 
14
15
  ## Configuration
15
16
 
16
17
  ### Streming inserts
17
18
 
18
- For service account authentication, generate service account private key file and email key, then upload private key file onto your server.
19
-
20
19
  Configure insert specifications with target table schema, with your credentials. This is minimum configurations:
21
20
 
22
21
  ```apache
@@ -25,6 +24,7 @@ Configure insert specifications with target table schema, with your credentials.
25
24
 
26
25
  method insert # default
27
26
 
27
+ auth_method private_key # default
28
28
  email xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com
29
29
  private_key_path /home/username/.keys/00000000000000000000000000000000-privatekey.p12
30
30
  # private_key_passphrase notasecret # default
@@ -58,6 +58,7 @@ For high rate inserts over streaming inserts, you should specify flush intervals
58
58
 
59
59
  num_threads 16
60
60
 
61
+ auth_method private_key # default
61
62
  email xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com
62
63
  private_key_path /home/username/.keys/00000000000000000000000000000000-privatekey.p12
63
64
  # private_key_passphrase notasecret # default
@@ -100,6 +101,41 @@ Important options for high rate events are:
100
101
  * `1` is lowest value, without patches on Fluentd v0.10.41 or earlier
101
102
  * see `patches` below
102
103
 
104
+ ### Authentication
105
+
106
+ There are two methods supported to fetch access token for the service account.
107
+ 1. Public-Private key pair
108
+ 2. Predefined access token (Compute Engine only)
109
+
110
+ The examples above use the first one. You first need to create a service account (client ID),
111
+ download its private key and deploy the key with fluentd.
112
+
113
+ On the other hand, you don't need to explicitly create a service account for fluentd when you
114
+ run fluentd in Google Compute Engine. In this second authentication method, you need to
115
+ add the API scope "https://www.googleapis.com/auth/bigquery" to the scope list of your
116
+ Compute Engine instance, then you can configure fluentd like this.
117
+
118
+ ```apache
119
+ <match dummy>
120
+ type bigquery
121
+
122
+ auth_method compute_engine
123
+
124
+ project yourproject_id
125
+ dataset yourdataset_id
126
+ table tablename
127
+
128
+ time_format %s
129
+ time_field time
130
+
131
+ field_integer time,status,bytes
132
+ field_string rhost,vhost,path,method,protocol,agent,referer
133
+ field_float requestime
134
+ field_boolean bot_access,loginsession
135
+ </match>
136
+ ```
137
+
138
+
103
139
  ### patches
104
140
 
105
141
  This plugin depends on `fluent-plugin-buffer-lightening`, and it includes monkey patch module for BufferedOutput plugin, to realize high rate and low latency flushing. With this patch, sub 1 second flushing available.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "rake"
22
- spec.add_runtime_dependency "google-api-client", "~> 0.6.4"
22
+ spec.add_runtime_dependency "google-api-client", "~> 0.7.1"
23
23
  spec.add_runtime_dependency "fluentd"
24
24
  spec.add_runtime_dependency "fluent-mixin-plaintextformatter", '>= 0.2.1'
25
25
  spec.add_runtime_dependency "fluent-mixin-config-placeholders", ">= 0.2.0"
@@ -1,6 +1,6 @@
1
1
  module Fluent
2
2
  module BigQueryPlugin
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
6
6
 
@@ -39,9 +39,14 @@ module Fluent
39
39
  # config_param :client_id, :string
40
40
  # config_param :client_secret, :string
41
41
 
42
+ # Available methods are:
43
+ # * private_key -- Use service account credential
44
+ # * compute_engine -- Use access token available in instances of ComputeEngine
45
+ config_param :auth_method, :string, :default => 'private_key'
46
+
42
47
  ### Service Account credential
43
- config_param :email, :string
44
- config_param :private_key_path, :string
48
+ config_param :email, :string, :default => nil
49
+ config_param :private_key_path, :string, :default => nil
45
50
  config_param :private_key_passphrase, :string, :default => 'notasecret'
46
51
 
47
52
  # see as simple reference
@@ -115,11 +120,23 @@ module Fluent
115
120
  require 'google/api_client'
116
121
  require 'google/api_client/client_secrets'
117
122
  require 'google/api_client/auth/installed_app'
123
+ require 'google/api_client/auth/compute_service_account'
118
124
  end
119
125
 
120
126
  def configure(conf)
121
127
  super
122
128
 
129
+ case @auth_method
130
+ when 'private_key'
131
+ if !@email || !@private_key_path
132
+ raise Fluent::ConfigError, "'email' and 'private_key_path' must be specified if auth_method == 'private_key'"
133
+ end
134
+ when 'compute_engine'
135
+ # Do nothing
136
+ else
137
+ raise Fluent::ConfigError, "unrecognized 'auth_method': #{@auth_method}"
138
+ end
139
+
123
140
  if (!@table && !@tables) || (@table && @table)
124
141
  raise Fluent::ConfigError, "'table' or 'tables' must be specified, and both are invalid"
125
142
  end
@@ -180,14 +197,26 @@ module Fluent
180
197
  :application_version => Fluent::BigQueryPlugin::VERSION
181
198
  )
182
199
 
183
- key = Google::APIClient::PKCS12.load_key( @private_key_path, @private_key_passphrase )
184
- asserter = Google::APIClient::JWTAsserter.new(
185
- @email,
186
- "https://www.googleapis.com/auth/bigquery",
187
- key
188
- )
189
- # refresh_auth
190
- client.authorization = asserter.authorize
200
+ case @auth_method
201
+ when 'private_key'
202
+ key = Google::APIClient::PKCS12.load_key( @private_key_path, @private_key_passphrase )
203
+ asserter = Google::APIClient::JWTAsserter.new(
204
+ @email,
205
+ "https://www.googleapis.com/auth/bigquery",
206
+ key
207
+ )
208
+ # refresh_auth
209
+ client.authorization = asserter.authorize
210
+
211
+ when 'compute_engine'
212
+ auth = Google::APIClient::ComputeServiceAccount.new
213
+ auth.fetch_access_token!
214
+ client.authorization = auth
215
+
216
+ else
217
+ raise ConfigError, "Unknown auth method: #{@auth_method}"
218
+ end
219
+
191
220
  @cached_client_expiration = Time.now + 1800
192
221
  @cached_client = client
193
222
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.4
33
+ version: 0.7.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.4
40
+ version: 0.7.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fluentd
43
43
  requirement: !ruby/object:Gem::Requirement