fluent-plugin-google-cloud 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ Gem::Specification.new do |gem|
|
|
4
4
|
gem.summary = %q{Fluentd plugin to stream logs to the Google Cloud Platform's logging API}
|
5
5
|
gem.homepage = 'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
|
6
6
|
gem.license = 'Apache 2.0'
|
7
|
-
gem.version = '0.
|
7
|
+
gem.version = '0.2.0'
|
8
8
|
gem.authors = ['Todd Derr', 'Alex Robinson']
|
9
9
|
gem.email = ['salty@google.com']
|
10
10
|
|
@@ -14,6 +14,8 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.add_runtime_dependency 'fluentd', '~> 0.10'
|
16
16
|
gem.add_runtime_dependency 'google-api-client', '~> 0.7'
|
17
|
+
gem.add_runtime_dependency 'signet', '~> 0.5.0'
|
17
18
|
gem.add_development_dependency "rake", '>= 10.3.2'
|
18
19
|
gem.add_development_dependency "webmock", '>= 1.17.0'
|
20
|
+
gem.add_development_dependency "minitest", '~> 4.0'
|
19
21
|
end
|
@@ -92,7 +92,7 @@ module Fluent
|
|
92
92
|
@zone = fully_qualified_zone.rpartition('/')[2]
|
93
93
|
@vm_id = fetch_metadata('instance/id')
|
94
94
|
# TODO: Send instance tags and/or hostname with the logs as well?
|
95
|
-
@common_labels =
|
95
|
+
@common_labels = {}
|
96
96
|
|
97
97
|
# If this is running on a Managed VM, grab the relevant App Engine
|
98
98
|
# metadata as well.
|
@@ -107,26 +107,21 @@ module Fluent
|
|
107
107
|
@gae_backend_version =
|
108
108
|
fetch_metadata('instance/attributes/gae_backend_version')
|
109
109
|
@service_name = APPENGINE_SERVICE
|
110
|
-
|
111
|
-
|
112
|
-
add_label(common_labels, "#{APPENGINE_SERVICE}/version_id",
|
113
|
-
'strValue', @gae_backend_version)
|
110
|
+
common_labels["#{APPENGINE_SERVICE}/module_id"] = @gae_backend_name
|
111
|
+
common_labels["#{APPENGINE_SERVICE}/version_id"] = @gae_backend_version
|
114
112
|
elsif (attributes.include?('job_id'))
|
115
113
|
@running_on_managed_vm = false
|
116
114
|
@service_name = DATAFLOW_SERVICE
|
117
115
|
@dataflow_job_id = fetch_metadata('instance/attributes/job_id')
|
118
|
-
|
119
|
-
'strValue', @dataflow_job_id)
|
116
|
+
common_labels["#{DATAFLOW_SERVICE}/job_id"] = @dataflow_job_id
|
120
117
|
else
|
121
118
|
@running_on_managed_vm = false
|
122
119
|
@service_name = COMPUTE_SERVICE
|
123
120
|
end
|
124
121
|
|
125
122
|
if (@service_name != DATAFLOW_SERVICE)
|
126
|
-
|
127
|
-
|
128
|
-
add_label(common_labels, "#{COMPUTE_SERVICE}/resource_id",
|
129
|
-
'strValue', @vm_id)
|
123
|
+
common_labels["#{COMPUTE_SERVICE}/resource_type"] = 'instance'
|
124
|
+
common_labels["#{COMPUTE_SERVICE}/resource_id"] = @vm_id
|
130
125
|
end
|
131
126
|
end
|
132
127
|
|
@@ -138,10 +133,6 @@ module Fluent
|
|
138
133
|
[tag, time, record].to_msgpack
|
139
134
|
end
|
140
135
|
|
141
|
-
def add_label(labels, key, type, value)
|
142
|
-
labels.push({'key' => key, type => value})
|
143
|
-
end
|
144
|
-
|
145
136
|
def write(chunk)
|
146
137
|
# Group the entries since we have to make one call per tag.
|
147
138
|
grouped_entries = {}
|
@@ -189,7 +180,7 @@ module Fluent
|
|
189
180
|
# and also escape the log name.
|
190
181
|
log_name = CGI::escape(@running_on_managed_vm ?
|
191
182
|
"#{APPENGINE_SERVICE}/#{tag}" : tag)
|
192
|
-
url = ('https://
|
183
|
+
url = ('https://logging.googleapis.com/v1beta3/projects/' +
|
193
184
|
"#{@project_id}/logs/#{log_name}/entries:write")
|
194
185
|
begin
|
195
186
|
client = api_client()
|
@@ -229,7 +220,7 @@ module Fluent
|
|
229
220
|
def init_api_client
|
230
221
|
@client = Google::APIClient.new(
|
231
222
|
:application_name => 'Fluentd Google Cloud Logging plugin',
|
232
|
-
:application_version => '0.
|
223
|
+
:application_version => '0.2.0',
|
233
224
|
:retries => 1)
|
234
225
|
|
235
226
|
if @auth_method == 'private_key'
|
@@ -84,8 +84,8 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
84
84
|
'service_name' => COMPUTE_SERVICE_NAME,
|
85
85
|
'log_name' => 'test',
|
86
86
|
'labels' => {
|
87
|
-
"#{COMPUTE_SERVICE_NAME}/resource_type" =>
|
88
|
-
"#{COMPUTE_SERVICE_NAME}/resource_id" =>
|
87
|
+
"#{COMPUTE_SERVICE_NAME}/resource_type" => 'instance',
|
88
|
+
"#{COMPUTE_SERVICE_NAME}/resource_id" => VM_ID
|
89
89
|
}
|
90
90
|
}
|
91
91
|
|
@@ -93,12 +93,10 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
93
93
|
'service_name' => APPENGINE_SERVICE_NAME,
|
94
94
|
'log_name' => "#{APPENGINE_SERVICE_NAME}%2Ftest",
|
95
95
|
'labels' => {
|
96
|
-
"#{APPENGINE_SERVICE_NAME}/module_id" =>
|
97
|
-
|
98
|
-
"#{
|
99
|
-
|
100
|
-
"#{COMPUTE_SERVICE_NAME}/resource_type" => ['strValue', 'instance'],
|
101
|
-
"#{COMPUTE_SERVICE_NAME}/resource_id" => ['strValue', VM_ID]
|
96
|
+
"#{APPENGINE_SERVICE_NAME}/module_id" => MANAGED_VM_BACKEND_NAME,
|
97
|
+
"#{APPENGINE_SERVICE_NAME}/version_id" => MANAGED_VM_BACKEND_VERSION,
|
98
|
+
"#{COMPUTE_SERVICE_NAME}/resource_type" => 'instance',
|
99
|
+
"#{COMPUTE_SERVICE_NAME}/resource_id" => VM_ID
|
102
100
|
}
|
103
101
|
}
|
104
102
|
|
@@ -287,7 +285,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
287
285
|
private
|
288
286
|
|
289
287
|
def uri_for_log(config)
|
290
|
-
'https://
|
288
|
+
'https://logging.googleapis.com/v1beta3/projects/' + PROJECT_ID +
|
291
289
|
'/logs/' + config['log_name'] + '/entries:write'
|
292
290
|
end
|
293
291
|
|
@@ -312,16 +310,12 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
312
310
|
|
313
311
|
def check_labels(entry, common_labels, expected_labels)
|
314
312
|
# TODO(salty) test/handle overlap between common_labels and entry labels
|
315
|
-
all_labels
|
316
|
-
all_labels.
|
317
|
-
|
318
|
-
assert expected_labels.has_key?(key), "Unexpected label #{
|
319
|
-
|
320
|
-
|
321
|
-
assert label.has_key?(expected_type),
|
322
|
-
"Type mismatch - expected #{expected_type} in #{label}"
|
323
|
-
assert_equal label[expected_type], expected_value,
|
324
|
-
"Value mismatch - expected #{expected_value} in #{label}"
|
313
|
+
all_labels ||= common_labels
|
314
|
+
all_labels.merge!(entry['metadata']['labels'] || {})
|
315
|
+
all_labels.each do |key, value|
|
316
|
+
assert expected_labels.has_key?(key), "Unexpected label #{key} => #{value}"
|
317
|
+
assert_equal value, expected_labels[key],
|
318
|
+
"Value mismatch - expected #{expected_labels[key]} in #{key} => #{value}"
|
325
319
|
end
|
326
320
|
assert_equal expected_labels.length, all_labels.length,
|
327
321
|
("Expected #{expected_labels.length} labels, got " +
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-google-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|
@@ -44,6 +44,22 @@ dependencies:
|
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0.7'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: signet
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.5.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.5.0
|
47
63
|
- !ruby/object:Gem::Dependency
|
48
64
|
name: rake
|
49
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +92,22 @@ dependencies:
|
|
76
92
|
- - ! '>='
|
77
93
|
- !ruby/object:Gem::Version
|
78
94
|
version: 1.17.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: minitest
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
79
111
|
description: Fluentd plugin to stream logs to the Google Cloud Platform's logging
|
80
112
|
API, which will make them viewable in the Developer Console's log viewer and can
|
81
113
|
optionally store them in Google Cloud Storage and/or BigQuery. This is an official
|