fluent-plugin-google-cloud 0.6.6 → 0.6.7.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/fluent-plugin-google-cloud.gemspec +1 -1
- data/lib/fluent/plugin/out_google_cloud.rb +330 -236
- data/test/plugin/base_test.rb +407 -46
- data/test/plugin/constants.rb +152 -13
- data/test/plugin/test_out_google_cloud.rb +2 -0
- metadata +4 -4
data/test/plugin/constants.rb
CHANGED
@@ -14,7 +14,9 @@
|
|
14
14
|
|
15
15
|
# Constants used by unit tests for Google Cloud Logging plugin.
|
16
16
|
module Constants
|
17
|
-
include Fluent::GoogleCloudOutput::
|
17
|
+
include Fluent::GoogleCloudOutput::ServiceConstants
|
18
|
+
include Fluent::GoogleCloudOutput::ConfigConstants
|
19
|
+
include Fluent::GoogleCloudOutput::InternalConstants
|
18
20
|
|
19
21
|
# Generic attributes.
|
20
22
|
HOSTNAME = Socket.gethostname
|
@@ -26,6 +28,10 @@ module Constants
|
|
26
28
|
FULLY_QUALIFIED_ZONE = 'projects/' + PROJECT_ID + '/zones/' + ZONE
|
27
29
|
VM_ID = '9876543210'
|
28
30
|
|
31
|
+
# Attributes used for the Metadata Agent resources.
|
32
|
+
METADATA_ZONE = 'us-central1-c'
|
33
|
+
METADATA_VM_ID = '0123456789'
|
34
|
+
|
29
35
|
# Attributes used for custom (overridden) configs.
|
30
36
|
CUSTOM_PROJECT_ID = 'test-custom-project-id'
|
31
37
|
CUSTOM_ZONE = 'us-custom-central1-b'
|
@@ -51,6 +57,16 @@ module Constants
|
|
51
57
|
MANAGED_VM_BACKEND_NAME = 'default'
|
52
58
|
MANAGED_VM_BACKEND_VERSION = 'guestbook2.0'
|
53
59
|
|
60
|
+
# Docker Container labels.
|
61
|
+
DOCKER_CONTAINER_ID = '0d0f03ff8d3c42688692536d1af77a28cd135c0a5c531f25a31'
|
62
|
+
DOCKER_CONTAINER_NAME = 'happy_hippo'
|
63
|
+
DOCKER_CONTAINER_STREAM_STDOUT = 'stdout'
|
64
|
+
DOCKER_CONTAINER_STREAM_STDERR = 'stderr'
|
65
|
+
# Timestamp for 1234567890 seconds and 987654321 nanoseconds since epoch.
|
66
|
+
DOCKER_CONTAINER_TIMESTAMP = '2009-02-13T23:31:30.987654321Z'
|
67
|
+
DOCKER_CONTAINER_SECONDS_EPOCH = 1_234_567_890
|
68
|
+
DOCKER_CONTAINER_NANOS = 987_654_321
|
69
|
+
|
54
70
|
# Container Engine / Kubernetes specific labels.
|
55
71
|
CONTAINER_CLUSTER_NAME = 'cluster-1'
|
56
72
|
CONTAINER_NAMESPACE_ID = '898268c8-4a36-11e5-9d81-42010af0194c'
|
@@ -120,6 +136,10 @@ module Constants
|
|
120
136
|
APPLICATION_DEFAULT_CONFIG = %(
|
121
137
|
)
|
122
138
|
|
139
|
+
DETECT_JSON_CONFIG = %(
|
140
|
+
detect_json true
|
141
|
+
)
|
142
|
+
|
123
143
|
# rubocop:disable Metrics/LineLength
|
124
144
|
PRIVATE_KEY_CONFIG = %(
|
125
145
|
auth_method private_key
|
@@ -145,6 +165,20 @@ module Constants
|
|
145
165
|
monitoring_type prometheus
|
146
166
|
)
|
147
167
|
|
168
|
+
ENABLE_METADATA_AGENT_CONFIG = %(
|
169
|
+
enable_metadata_agent true
|
170
|
+
)
|
171
|
+
|
172
|
+
DISABLE_METADATA_AGENT_CONFIG = %(
|
173
|
+
enable_metadata_agent false
|
174
|
+
)
|
175
|
+
|
176
|
+
DOCKER_CONTAINER_CONFIG = %(
|
177
|
+
enable_metadata_agent true
|
178
|
+
label_map { "source": "#{DOCKER_CONSTANTS[:service]}/stream" }
|
179
|
+
detect_json true
|
180
|
+
)
|
181
|
+
|
148
182
|
CUSTOM_METADATA_CONFIG = %(
|
149
183
|
project_id #{CUSTOM_PROJECT_ID}
|
150
184
|
zone #{CUSTOM_ZONE}
|
@@ -201,6 +235,8 @@ module Constants
|
|
201
235
|
)
|
202
236
|
|
203
237
|
# Service configurations for various services.
|
238
|
+
|
239
|
+
# GCE.
|
204
240
|
COMPUTE_PARAMS = {
|
205
241
|
resource: {
|
206
242
|
type: COMPUTE_CONSTANTS[:resource_type],
|
@@ -215,7 +251,16 @@ module Constants
|
|
215
251
|
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME
|
216
252
|
}
|
217
253
|
}
|
254
|
+
COMPUTE_PARAMS_WITH_METADATA_VM_ID_AND_ZONE = COMPUTE_PARAMS.merge(
|
255
|
+
resource: COMPUTE_PARAMS[:resource].merge(
|
256
|
+
labels: {
|
257
|
+
'instance_id' => METADATA_VM_ID,
|
258
|
+
'zone' => METADATA_ZONE
|
259
|
+
}
|
260
|
+
)
|
261
|
+
)
|
218
262
|
|
263
|
+
# GAE.
|
219
264
|
VMENGINE_PARAMS = {
|
220
265
|
resource: {
|
221
266
|
type: APPENGINE_CONSTANTS[:resource_type],
|
@@ -233,12 +278,13 @@ module Constants
|
|
233
278
|
}
|
234
279
|
}
|
235
280
|
|
281
|
+
# GKE Container.
|
236
282
|
CONTAINER_TAG = "kubernetes.#{CONTAINER_POD_NAME}_" \
|
237
283
|
"#{CONTAINER_NAMESPACE_NAME}_#{CONTAINER_CONTAINER_NAME}"
|
238
284
|
|
239
285
|
CONTAINER_FROM_METADATA_PARAMS = {
|
240
286
|
resource: {
|
241
|
-
type:
|
287
|
+
type: GKE_CONSTANTS[:resource_type],
|
242
288
|
labels: {
|
243
289
|
'cluster_name' => CONTAINER_CLUSTER_NAME,
|
244
290
|
'namespace_id' => CONTAINER_NAMESPACE_ID,
|
@@ -251,10 +297,10 @@ module Constants
|
|
251
297
|
log_name: CONTAINER_CONTAINER_NAME,
|
252
298
|
project_id: PROJECT_ID,
|
253
299
|
labels: {
|
254
|
-
"#{
|
300
|
+
"#{GKE_CONSTANTS[:service]}/namespace_name" =>
|
255
301
|
CONTAINER_NAMESPACE_NAME,
|
256
|
-
"#{
|
257
|
-
"#{
|
302
|
+
"#{GKE_CONSTANTS[:service]}/pod_name" => CONTAINER_POD_NAME,
|
303
|
+
"#{GKE_CONSTANTS[:service]}/stream" => CONTAINER_STREAM,
|
258
304
|
"label/#{CONTAINER_LABEL_KEY}" => CONTAINER_LABEL_VALUE,
|
259
305
|
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME
|
260
306
|
}
|
@@ -264,7 +310,7 @@ module Constants
|
|
264
310
|
# namespace and pod names.
|
265
311
|
CONTAINER_FROM_TAG_PARAMS = {
|
266
312
|
resource: {
|
267
|
-
type:
|
313
|
+
type: GKE_CONSTANTS[:resource_type],
|
268
314
|
labels: {
|
269
315
|
'cluster_name' => CONTAINER_CLUSTER_NAME,
|
270
316
|
'namespace_id' => CONTAINER_NAMESPACE_NAME,
|
@@ -277,14 +323,58 @@ module Constants
|
|
277
323
|
log_name: CONTAINER_CONTAINER_NAME,
|
278
324
|
project_id: PROJECT_ID,
|
279
325
|
labels: {
|
280
|
-
"#{
|
326
|
+
"#{GKE_CONSTANTS[:service]}/namespace_name" =>
|
281
327
|
CONTAINER_NAMESPACE_NAME,
|
282
|
-
"#{
|
283
|
-
"#{
|
328
|
+
"#{GKE_CONSTANTS[:service]}/pod_name" => CONTAINER_POD_NAME,
|
329
|
+
"#{GKE_CONSTANTS[:service]}/stream" => CONTAINER_STREAM,
|
284
330
|
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME
|
285
331
|
}
|
286
332
|
}
|
287
333
|
|
334
|
+
CONTAINER_FROM_APPLICATION_PARAMS = {
|
335
|
+
resource: {
|
336
|
+
type: GKE_CONSTANTS[:resource_type],
|
337
|
+
labels: {
|
338
|
+
'cluster_name' => CONTAINER_CLUSTER_NAME,
|
339
|
+
'namespace_id' => CONTAINER_NAMESPACE_ID,
|
340
|
+
'instance_id' => VM_ID,
|
341
|
+
'pod_id' => CONTAINER_POD_ID,
|
342
|
+
'container_name' => CONTAINER_CONTAINER_NAME,
|
343
|
+
'zone' => ZONE
|
344
|
+
}
|
345
|
+
},
|
346
|
+
log_name: 'redis',
|
347
|
+
project_id: PROJECT_ID,
|
348
|
+
labels: {
|
349
|
+
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
# Docker Container.
|
354
|
+
DOCKER_CONTAINER_PARAMS = {
|
355
|
+
resource: {
|
356
|
+
type: DOCKER_CONSTANTS[:resource_type],
|
357
|
+
labels: {
|
358
|
+
'container_id' => DOCKER_CONTAINER_ID,
|
359
|
+
'location' => ZONE
|
360
|
+
}
|
361
|
+
},
|
362
|
+
log_name: 'test',
|
363
|
+
project_id: PROJECT_ID,
|
364
|
+
labels: {
|
365
|
+
"#{DOCKER_CONSTANTS[:service]}/stream" => DOCKER_CONTAINER_STREAM_STDOUT
|
366
|
+
}
|
367
|
+
}
|
368
|
+
DOCKER_CONTAINER_PARAMS_WITH_STREAM_STDERR = DOCKER_CONTAINER_PARAMS.merge(
|
369
|
+
labels: DOCKER_CONTAINER_PARAMS[:labels].merge(
|
370
|
+
"#{DOCKER_CONSTANTS[:service]}/stream" => DOCKER_CONTAINER_STREAM_STDERR
|
371
|
+
)
|
372
|
+
)
|
373
|
+
DOCKER_CONTAINER_PARAMS_WITH_NO_STREAM = DOCKER_CONTAINER_PARAMS.merge(
|
374
|
+
labels: {}
|
375
|
+
)
|
376
|
+
|
377
|
+
# Cloud Functions.
|
288
378
|
CLOUDFUNCTIONS_TAG = "kubernetes.#{CLOUDFUNCTIONS_POD_NAME}_" \
|
289
379
|
"#{CLOUDFUNCTIONS_NAMESPACE_NAME}_" \
|
290
380
|
"#{CLOUDFUNCTIONS_CONTAINER_NAME}"
|
@@ -301,8 +391,8 @@ module Constants
|
|
301
391
|
project_id: PROJECT_ID,
|
302
392
|
labels: {
|
303
393
|
'execution_id' => CLOUDFUNCTIONS_EXECUTION_ID,
|
304
|
-
"#{
|
305
|
-
"#{
|
394
|
+
"#{GKE_CONSTANTS[:service]}/instance_id" => VM_ID,
|
395
|
+
"#{GKE_CONSTANTS[:service]}/cluster_name" =>
|
306
396
|
CLOUDFUNCTIONS_CLUSTER_NAME,
|
307
397
|
"#{COMPUTE_CONSTANTS[:service]}/resource_id" => VM_ID,
|
308
398
|
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME,
|
@@ -321,8 +411,8 @@ module Constants
|
|
321
411
|
log_name: 'cloud-functions',
|
322
412
|
project_id: PROJECT_ID,
|
323
413
|
labels: {
|
324
|
-
"#{
|
325
|
-
"#{
|
414
|
+
"#{GKE_CONSTANTS[:service]}/instance_id" => VM_ID,
|
415
|
+
"#{GKE_CONSTANTS[:service]}/cluster_name" =>
|
326
416
|
CLOUDFUNCTIONS_CLUSTER_NAME,
|
327
417
|
"#{COMPUTE_CONSTANTS[:service]}/resource_id" => VM_ID,
|
328
418
|
"#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME,
|
@@ -330,6 +420,7 @@ module Constants
|
|
330
420
|
}
|
331
421
|
}
|
332
422
|
|
423
|
+
# Cloud Dataflow.
|
333
424
|
DATAFLOW_PARAMS = {
|
334
425
|
resource: {
|
335
426
|
type: DATAFLOW_CONSTANTS[:resource_type],
|
@@ -349,6 +440,7 @@ module Constants
|
|
349
440
|
}
|
350
441
|
}
|
351
442
|
|
443
|
+
# Cloud Dataproc.
|
352
444
|
DATAPROC_PARAMS = {
|
353
445
|
resource: {
|
354
446
|
type: DATAPROC_CONSTANTS[:resource_type],
|
@@ -367,6 +459,7 @@ module Constants
|
|
367
459
|
}
|
368
460
|
}
|
369
461
|
|
462
|
+
# Cloud ML.
|
370
463
|
ML_PARAMS = {
|
371
464
|
resource: {
|
372
465
|
type: ML_CONSTANTS[:resource_type],
|
@@ -477,4 +570,50 @@ module Constants
|
|
477
570
|
'' => '_'
|
478
571
|
}
|
479
572
|
ALL_TAGS = VALID_TAGS.merge(INVALID_TAGS)
|
573
|
+
|
574
|
+
# Stub value for Monitored resources from Metadata Agent.
|
575
|
+
# Map from the local_resource_id to the retrieved monitored resource.
|
576
|
+
MONITORED_RESOURCE_STUBS = {
|
577
|
+
# Implicit GCE instance.
|
578
|
+
IMPLICIT_LOCAL_RESOURCE_ID =>
|
579
|
+
{
|
580
|
+
'type' => COMPUTE_CONSTANTS[:resource_type],
|
581
|
+
'labels' => {
|
582
|
+
'zone' => METADATA_ZONE,
|
583
|
+
'instance_id' => METADATA_VM_ID
|
584
|
+
}
|
585
|
+
}.to_json,
|
586
|
+
# Docker container stderr / stdout logs.
|
587
|
+
"container.#{DOCKER_CONTAINER_ID}" =>
|
588
|
+
{
|
589
|
+
'type' => DOCKER_CONSTANTS[:resource_type],
|
590
|
+
'labels' => {
|
591
|
+
'location' => ZONE,
|
592
|
+
'container_id' => DOCKER_CONTAINER_ID
|
593
|
+
}
|
594
|
+
}.to_json,
|
595
|
+
# Docker container application logs.
|
596
|
+
"containerName.#{DOCKER_CONTAINER_NAME}" =>
|
597
|
+
{
|
598
|
+
'type' => DOCKER_CONSTANTS[:resource_type],
|
599
|
+
'labels' => {
|
600
|
+
'location' => ZONE,
|
601
|
+
'container_id' => DOCKER_CONTAINER_ID
|
602
|
+
}
|
603
|
+
}.to_json,
|
604
|
+
# GKE container logs.
|
605
|
+
"gke_containerName.#{CONTAINER_NAMESPACE_ID}.#{CONTAINER_POD_NAME}." \
|
606
|
+
"#{CONTAINER_CONTAINER_NAME}" =>
|
607
|
+
{
|
608
|
+
'type' => GKE_CONSTANTS[:resource_type],
|
609
|
+
'labels' => {
|
610
|
+
'cluster_name' => CONTAINER_CLUSTER_NAME,
|
611
|
+
'container_name' => CONTAINER_CONTAINER_NAME,
|
612
|
+
'instance_id' => VM_ID,
|
613
|
+
'namespace_id' => CONTAINER_NAMESPACE_ID,
|
614
|
+
'pod_id' => CONTAINER_POD_ID,
|
615
|
+
'zone' => ZONE
|
616
|
+
}
|
617
|
+
}.to_json
|
618
|
+
}
|
480
619
|
end
|
@@ -185,6 +185,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
185
185
|
|
186
186
|
# synonyms for existing log levels
|
187
187
|
assert_equal('ERROR', test_obj.parse_severity('ERR'))
|
188
|
+
assert_equal('ERROR', test_obj.parse_severity('SEVERE'))
|
188
189
|
assert_equal('WARNING', test_obj.parse_severity('WARN'))
|
189
190
|
assert_equal('CRITICAL', test_obj.parse_severity('FATAL'))
|
190
191
|
assert_equal('DEBUG', test_obj.parse_severity('TRACE'))
|
@@ -192,6 +193,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
192
193
|
assert_equal('DEBUG', test_obj.parse_severity('FINE'))
|
193
194
|
assert_equal('DEBUG', test_obj.parse_severity('FINER'))
|
194
195
|
assert_equal('DEBUG', test_obj.parse_severity('FINEST'))
|
196
|
+
assert_equal('DEBUG', test_obj.parse_severity('CONFIG'))
|
195
197
|
|
196
198
|
# single letters.
|
197
199
|
assert_equal('DEBUG', test_obj.parse_severity('D'))
|
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.6.
|
4
|
+
version: 0.6.7.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Derr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -249,9 +249,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '2.0'
|
250
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
251
|
requirements:
|
252
|
-
- - "
|
252
|
+
- - ">"
|
253
253
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
254
|
+
version: 1.3.1
|
255
255
|
requirements: []
|
256
256
|
rubyforge_project:
|
257
257
|
rubygems_version: 2.4.8
|