fluent-plugin-google-cloud 0.6.8.pre.1 → 0.6.8.pre.2

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: f013270937ffeb8ac1addeb0b50cbd04b9434d8f
4
- data.tar.gz: a19be3b8f5b49266e6055be20c6a8c693fae1fea
3
+ metadata.gz: 5f2c640c0609198df6d95e33e06d442806ecb5f2
4
+ data.tar.gz: 842c10c9b0d881cec2bfcd272b13ac3e7ab915b6
5
5
  SHA512:
6
- metadata.gz: cfc74c7b17e028776423d30fbc438d1d5d146d532991bb2331044a35f54e1a6acfd6f14e6bc4b234f924ac5e6d62b268931b8c856d07532b9c610c85579f3906
7
- data.tar.gz: bb14fdffce9b35b5c1ff4d9609d5ec473d19d69b74972b3ba20bc843d28e1118be19b89b112b961d7b903e246612eca551780c3e9c202fa852ad8bdec6f50f2d
6
+ metadata.gz: d1e3a20210418858232b925e2d35255e78564170d0d8f391c20d7d8700bf4d3a52bec63e8c82fa02ff5fccbbad117097672637b30803d1e5b3348f7ac1b248ff
7
+ data.tar.gz: e9787a02f9be79bbc2d37594d3718446d8c7a197455201b2c772fd36223783c9bbe5a77e4c69b387b1dbc8e30afd739d88c001281f759e62f033c0eedd3e3431
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.6.8.pre.1)
4
+ fluent-plugin-google-cloud (0.6.8.pre.2)
5
5
  fluentd (~> 0.10)
6
6
  google-api-client (~> 0.9.0)
7
7
  google-cloud-logging (= 0.24.1)
@@ -23,7 +23,7 @@ GEM
23
23
  safe_yaml (~> 1.0.0)
24
24
  faraday (0.13.1)
25
25
  multipart-post (>= 1.2, < 3)
26
- fluentd (0.14.20)
26
+ fluentd (0.14.21)
27
27
  cool.io (>= 1.4.5, < 2.0.0)
28
28
  http_parser.rb (>= 0.5.1, < 0.7.0)
29
29
  msgpack (>= 0.7.0, < 2.0.0)
@@ -49,16 +49,19 @@ GEM
49
49
  google-cloud-core (~> 0.21.1)
50
50
  google-gax (~> 0.8.0)
51
51
  stackdriver-core (~> 0.21.0)
52
- google-gax (0.8.6)
52
+ google-gax (0.8.7)
53
53
  google-protobuf (~> 3.2)
54
54
  googleapis-common-protos (~> 1.3.5)
55
55
  googleauth (~> 0.5.1)
56
56
  grpc (~> 1.0)
57
57
  rly (~> 0.2.3)
58
- google-protobuf (3.4.0.2)
59
- googleapis-common-protos (1.3.5)
60
- google-protobuf (~> 3.2)
58
+ google-protobuf (3.4.1.1-x86_64-linux)
59
+ googleapis-common-protos (1.3.6)
60
+ google-protobuf (~> 3.0)
61
+ googleapis-common-protos-types (~> 1.0)
61
62
  grpc (~> 1.0)
63
+ googleapis-common-protos-types (1.0.0)
64
+ google-protobuf (~> 3.0)
62
65
  googleauth (0.5.1)
63
66
  faraday (~> 0.9)
64
67
  jwt (~> 1.4)
@@ -67,7 +70,7 @@ GEM
67
70
  multi_json (~> 1.11)
68
71
  os (~> 0.9)
69
72
  signet (~> 0.7)
70
- grpc (1.2.5)
73
+ grpc (1.2.5-x86_64-linux)
71
74
  google-protobuf (~> 3.1)
72
75
  googleauth (~> 0.5.1)
73
76
  hashdiff (0.3.6)
@@ -113,7 +116,7 @@ GEM
113
116
  rainbow (>= 1.99.1, < 3.0)
114
117
  ruby-progressbar (~> 1.7)
115
118
  tins (<= 1.6.0)
116
- ruby-progressbar (1.8.1)
119
+ ruby-progressbar (1.8.3)
117
120
  ruby_dig (0.0.2)
118
121
  safe_yaml (1.0.4)
119
122
  serverengine (2.0.5)
@@ -126,7 +129,7 @@ GEM
126
129
  multi_json (~> 1.10)
127
130
  stackdriver-core (0.21.0)
128
131
  strptime (0.1.9)
129
- test-unit (3.2.5)
132
+ test-unit (3.2.6)
130
133
  power_assert
131
134
  thread_safe (0.3.6)
132
135
  tins (1.6.0)
@@ -10,7 +10,7 @@ eos
10
10
  gem.homepage = \
11
11
  'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
12
12
  gem.license = 'Apache-2.0'
13
- gem.version = '0.6.8.pre.1'
13
+ gem.version = '0.6.8.pre.2'
14
14
  gem.authors = ['Todd Derr', 'Alex Robinson']
15
15
  gem.email = ['salty@google.com']
16
16
  gem.required_ruby_version = Gem::Requirement.new('>= 2.0')
@@ -114,10 +114,6 @@ module Fluent
114
114
 
115
115
  # Constants for log entry field extraction.
116
116
  module InternalConstants
117
- # Use empty string as request path when the local_resource_id of monitored
118
- # resource can be implicitly inferred by Metadata Agent.
119
- IMPLICIT_LOCAL_RESOURCE_ID = ''
120
-
121
117
  # The label name of local_resource_id in the json payload. When a record
122
118
  # has this field in the payload, we will use the value to retrieve
123
119
  # monitored resource from Stackdriver Metadata agent.
@@ -181,7 +177,7 @@ module Fluent
181
177
  Fluent::Plugin.register_output('google_cloud', self)
182
178
 
183
179
  PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'
184
- PLUGIN_VERSION = '0.6.8.pre.1'
180
+ PLUGIN_VERSION = '0.6.8.pre.2'
185
181
 
186
182
  # Name of the the Google cloud logging write scope.
187
183
  LOGGING_SCOPE = 'https://www.googleapis.com/auth/logging.write'
@@ -359,6 +355,11 @@ module Fluent
359
355
  @dropped_entries_count = registry.counter(
360
356
  :stackdriver_dropped_entries_count,
361
357
  'A number of log entries dropped by the Stackdriver output plugin')
358
+ @retried_entries_count = registry.counter(
359
+ :stackdriver_retried_entries_count,
360
+ 'The number of log entries that failed to be ingested by the'\
361
+ ' Stackdriver output plugin due to a transient error and were'\
362
+ ' retried')
362
363
  end
363
364
 
364
365
  # Alert on old authentication configuration.
@@ -380,19 +381,6 @@ module Fluent
380
381
 
381
382
  @platform = detect_platform
382
383
 
383
- # Set agent-level monitored resource. This monitored resource is initiated
384
- # as the logging agent starts up. It will be inherited by all log entries
385
- # processed by this agent. First try to retrieve it via Metadata Agent.
386
- if @enable_metadata_agent
387
- # The local_resource_id for this should be the instance id. Since this
388
- # can be implicitly inferred by Metadata Agent, we do not need to
389
- # explicitly send the key.
390
- # TODO(qingling128): Remove this logic once the resource is retrieved at
391
- # a proper time (b/65175256).
392
- @resource = query_metadata_agent_for_monitored_resource(
393
- IMPLICIT_LOCAL_RESOURCE_ID)
394
- end
395
-
396
384
  # Set required variables: @project_id, @vm_id, @vm_name and @zone.
397
385
  set_required_metadata_variables
398
386
 
@@ -575,9 +563,10 @@ module Fluent
575
563
  entries: entries
576
564
  )
577
565
 
566
+ entries_count = entries.length
578
567
  client.write_log_entries(write_request)
579
568
  increment_successful_requests_count
580
- increment_ingested_entries_count(entries.length)
569
+ increment_ingested_entries_count(entries_count)
581
570
 
582
571
  # Let the user explicitly know when the first call succeeded, to aid
583
572
  # with verification and troubleshooting.
@@ -588,7 +577,10 @@ module Fluent
588
577
 
589
578
  rescue GRPC::Cancelled => error
590
579
  increment_failed_requests_count(GRPC::Core::StatusCodes::CANCELLED)
580
+ increment_retried_entries_count(entries_count, error.code)
591
581
  # RPC cancelled, so retry via re-raising the error.
582
+ @log.debug "Retrying #{entries_count} log message(s) later.",
583
+ error: error.to_s, error_code: error.code.to_s
592
584
  raise error
593
585
 
594
586
  rescue GRPC::BadStatus => error
@@ -599,32 +591,31 @@ module Fluent
599
591
  GRPC::Core::StatusCodes::DEADLINE_EXCEEDED,
600
592
  GRPC::Core::StatusCodes::INTERNAL,
601
593
  GRPC::Core::StatusCodes::UNKNOWN
602
- # TODO
603
594
  # Server error, so retry via re-raising the error.
595
+ increment_retried_entries_count(entries.length, error.code)
596
+ @log.debug "Retrying #{entries_count} log message(s) later.",
597
+ error: error.to_s, error_code: error.code.to_s
604
598
  raise error
605
599
  when GRPC::Core::StatusCodes::UNIMPLEMENTED,
606
600
  GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED
607
601
  # Most client errors indicate a problem with the request itself
608
602
  # and should not be retried.
609
- dropped = entries.length
610
- increment_dropped_entries_count(dropped)
611
- @log.warn "Dropping #{dropped} log message(s)",
603
+ increment_dropped_entries_count(entries_count)
604
+ @log.warn "Dropping #{entries_count} log message(s)",
612
605
  error: error.to_s, error_code: error.code.to_s
613
606
  when GRPC::Core::StatusCodes::UNAUTHENTICATED
614
607
  # Authorization error.
615
608
  # These are usually solved via a `gcloud auth` call, or by
616
609
  # modifying the permissions on the Google Cloud project.
617
- dropped = entries.length
618
- increment_dropped_entries_count(dropped)
619
- @log.warn "Dropping #{dropped} log message(s)",
610
+ increment_dropped_entries_count(entries_count)
611
+ @log.warn "Dropping #{entries_count} log message(s)",
620
612
  error: error.to_s, error_code: error.code.to_s
621
613
  else
622
614
  # Assume this is a problem with the request itself and don't
623
615
  # retry.
624
- dropped = entries.length
625
- increment_dropped_entries_count(dropped)
616
+ increment_dropped_entries_count(entries_count)
626
617
  @log.error "Unknown response code #{error.code} from the "\
627
- "server, dropping #{dropped} log message(s)",
618
+ "server, dropping #{entries_count} log message(s)",
628
619
  error: error.to_s, error_code: error.code.to_s
629
620
  end
630
621
  end
@@ -636,6 +627,7 @@ module Fluent
636
627
  resource: group_level_resource,
637
628
  labels: group_level_common_labels,
638
629
  entries: entries)
630
+ entries_count = entries.length
639
631
 
640
632
  # TODO: RequestOptions
641
633
  begin
@@ -645,7 +637,7 @@ module Fluent
645
637
  raise error
646
638
  end
647
639
  increment_successful_requests_count
648
- increment_ingested_entries_count(entries.length)
640
+ increment_ingested_entries_count(entries_count)
649
641
 
650
642
  # Let the user explicitly know when the first call succeeded, to aid
651
643
  # with verification and troubleshooting.
@@ -656,23 +648,24 @@ module Fluent
656
648
 
657
649
  rescue Google::Apis::ServerError => error
658
650
  # Server error, so retry via re-raising the error.
651
+ increment_retried_entries_count(entries.length, error.status_code)
652
+ @log.debug "Retrying #{entries_count} log message(s) later.",
653
+ error: error.to_s, error_code: error.status_code.to_s
659
654
  raise error
660
655
 
661
656
  rescue Google::Apis::AuthorizationError => error
662
657
  # Authorization error.
663
658
  # These are usually solved via a `gcloud auth` call, or by modifying
664
659
  # the permissions on the Google Cloud project.
665
- dropped = entries.length
666
- increment_dropped_entries_count(dropped)
667
- @log.warn "Dropping #{dropped} log message(s)",
660
+ increment_dropped_entries_count(entries_count)
661
+ @log.warn "Dropping #{entries_count} log message(s)",
668
662
  error_class: error.class.to_s, error: error.to_s
669
663
 
670
664
  rescue Google::Apis::ClientError => error
671
665
  # Most ClientErrors indicate a problem with the request itself and
672
666
  # should not be retried.
673
- dropped = entries.length
674
- increment_dropped_entries_count(dropped)
675
- @log.warn "Dropping #{dropped} log message(s)",
667
+ increment_dropped_entries_count(entries_count)
668
+ @log.warn "Dropping #{entries_count} log message(s)",
676
669
  error_class: error.class.to_s, error: error.to_s
677
670
  end
678
671
  end
@@ -1186,7 +1179,7 @@ module Fluent
1186
1179
  begin
1187
1180
  resource = Google::Api::MonitoredResource.decode_json(response.to_json)
1188
1181
  rescue Google::Protobuf::ParseError, ArgumentError => e
1189
- @log.error 'Error paring monitored resource from Metadata Agent. ' \
1182
+ @log.error 'Error parsing monitored resource from Metadata Agent. ' \
1190
1183
  "response: #{response.inspect}", error: e
1191
1184
  return nil
1192
1185
  end
@@ -1743,6 +1736,13 @@ module Fluent
1743
1736
  return unless @dropped_entries_count
1744
1737
  @dropped_entries_count.increment({}, count)
1745
1738
  end
1739
+
1740
+ # Increment the metric for the number of log entries that were dropped
1741
+ # and not ingested by the Stackdriver Logging API.
1742
+ def increment_retried_entries_count(count, code)
1743
+ return unless @retried_entries_count
1744
+ @retried_entries_count.increment({ code: code }, count)
1745
+ end
1746
1746
  end
1747
1747
  end
1748
1748
 
@@ -1123,25 +1123,6 @@ module BaseTest
1123
1123
  setup_metadata_agent_stubs
1124
1124
  d = create_driver(ENABLE_METADATA_AGENT_CONFIG)
1125
1125
  assert_true d.instance.instance_variable_get(:@enable_metadata_agent)
1126
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1127
- end
1128
- end
1129
-
1130
- # Test that an implicit monitored resource can be retrieved from Metadata
1131
- # Agent with an empty string as the local_resource_id.
1132
- def test_retrieve_implicit_monitored_resource
1133
- # GCE metadata stubs has VM_ID and ZONE, while the Metadata Agent stub has
1134
- # METADATA_VM_ID and METADATA_ZONE.
1135
- new_stub_context do
1136
- setup_gce_metadata_stubs
1137
- setup_metadata_agent_stubs
1138
- setup_logging_stubs do
1139
- d = create_driver(ENABLE_METADATA_AGENT_CONFIG)
1140
- d.emit('message' => log_entry(0))
1141
- d.run
1142
- end
1143
- verify_log_entries(1, COMPUTE_PARAMS_WITH_METADATA_VM_ID_AND_ZONE)
1144
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1145
1126
  end
1146
1127
  end
1147
1128
 
@@ -1161,7 +1142,6 @@ module BaseTest
1161
1142
  d.run
1162
1143
  end
1163
1144
  verify_log_entries(n, DOCKER_CONTAINER_PARAMS)
1164
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1165
1145
  assert_requested_metadata_agent_stub("container.#{DOCKER_CONTAINER_ID}")
1166
1146
  end
1167
1147
  end
@@ -1191,7 +1171,6 @@ module BaseTest
1191
1171
  assert_equal 'test', get_string(fields['tag2']), entry
1192
1172
  assert_equal 5000, get_number(fields['data']), entry
1193
1173
  end
1194
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1195
1174
  assert_requested_metadata_agent_stub("container.#{DOCKER_CONTAINER_ID}")
1196
1175
  end
1197
1176
  end
@@ -1212,7 +1191,6 @@ module BaseTest
1212
1191
  d.run
1213
1192
  end
1214
1193
  verify_log_entries(1, DOCKER_CONTAINER_PARAMS_NO_STREAM)
1215
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1216
1194
  assert_requested_metadata_agent_stub(
1217
1195
  "containerName.#{DOCKER_CONTAINER_NAME}")
1218
1196
  end
@@ -1237,7 +1215,6 @@ module BaseTest
1237
1215
  assert_equal DOCKER_CONTAINER_NANOS,
1238
1216
  entry['timestamp']['nanos'], entry
1239
1217
  end
1240
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1241
1218
  assert_requested_metadata_agent_stub(
1242
1219
  "containerName.#{DOCKER_CONTAINER_NAME}")
1243
1220
  end
@@ -1289,7 +1266,6 @@ module BaseTest
1289
1266
  d.run
1290
1267
  end
1291
1268
  verify_log_entries(n, CONTAINER_FROM_APPLICATION_PARAMS)
1292
- assert_requested_metadata_agent_stub(IMPLICIT_LOCAL_RESOURCE_ID)
1293
1269
  assert_requested_metadata_agent_stub(
1294
1270
  "gke_containerName.#{CONTAINER_NAMESPACE_ID}.#{CONTAINER_POD_NAME}." \
1295
1271
  "#{CONTAINER_CONTAINER_NAME}")
@@ -572,15 +572,6 @@ module Constants
572
572
  # Stub value for Monitored resources from Metadata Agent.
573
573
  # Map from the local_resource_id to the retrieved monitored resource.
574
574
  MONITORED_RESOURCE_STUBS = {
575
- # Implicit GCE instance.
576
- IMPLICIT_LOCAL_RESOURCE_ID =>
577
- {
578
- 'type' => COMPUTE_CONSTANTS[:resource_type],
579
- 'labels' => {
580
- 'zone' => METADATA_ZONE,
581
- 'instance_id' => METADATA_VM_ID
582
- }
583
- }.to_json,
584
575
  # Docker container stderr / stdout logs.
585
576
  "container.#{DOCKER_CONTAINER_ID}" =>
586
577
  {
@@ -77,15 +77,16 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
77
77
  setup_gce_metadata_stubs
78
78
  [
79
79
  # Single successful request.
80
- [200, 1, 1, [1, 0, 1, 0]],
80
+ [200, 1, 1, [1, 0, 1, 0, 0]],
81
81
  # Several successful requests.
82
- [200, 2, 1, [2, 0, 2, 0]],
82
+ [200, 2, 1, [2, 0, 2, 0, 0]],
83
83
  # Single successful request with several entries.
84
- [200, 1, 2, [1, 0, 2, 0]],
84
+ [200, 1, 2, [1, 0, 2, 0, 0]],
85
85
  # Single failed request that causes logs to be dropped.
86
- [401, 1, 1, [0, 1, 0, 1]],
87
- # Single failed request that escalates without logs being dropped.
88
- [500, 1, 1, [0, 1, 0, 0]]
86
+ [401, 1, 1, [0, 1, 0, 1, 0]],
87
+ # Single failed request that escalates without logs being dropped with
88
+ # several entries.
89
+ [500, 1, 2, [0, 1, 0, 0, 2]]
89
90
  ].each do |code, request_count, entry_count, metric_values|
90
91
  setup_prometheus
91
92
  # TODO: Do this as part of setup_logging_stubs.
@@ -105,7 +106,8 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
105
106
  # rubocop:enable Lint/HandleExceptions
106
107
  end
107
108
  successful_requests_count, failed_requests_count,
108
- ingested_entries_count, dropped_entries_count = metric_values
109
+ ingested_entries_count, dropped_entries_count,
110
+ retried_entries_count = metric_values
109
111
  assert_prometheus_metric_value(:stackdriver_successful_requests_count,
110
112
  successful_requests_count, grpc: false)
111
113
  assert_prometheus_metric_value(:stackdriver_failed_requests_count,
@@ -115,6 +117,8 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
115
117
  ingested_entries_count)
116
118
  assert_prometheus_metric_value(:stackdriver_dropped_entries_count,
117
119
  dropped_entries_count)
120
+ assert_prometheus_metric_value(:stackdriver_retried_entries_count,
121
+ retried_entries_count, code: code)
118
122
  end
119
123
  end
120
124
 
@@ -79,15 +79,16 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
79
79
  setup_gce_metadata_stubs
80
80
  [
81
81
  # Single successful request.
82
- [false, 0, 1, 1, [1, 0, 1, 0]],
82
+ [false, 0, 1, 1, [1, 0, 1, 0, 0]],
83
83
  # Several successful requests.
84
- [false, 0, 2, 1, [2, 0, 2, 0]],
84
+ [false, 0, 2, 1, [2, 0, 2, 0, 0]],
85
85
  # Single successful request with several entries.
86
- [false, 0, 1, 2, [1, 0, 2, 0]],
86
+ [false, 0, 1, 2, [1, 0, 2, 0, 0]],
87
87
  # Single failed request that causes logs to be dropped.
88
- [true, 16, 1, 1, [0, 1, 0, 1]],
89
- # Single failed request that escalates without logs being dropped.
90
- [true, 13, 1, 1, [0, 1, 0, 0]]
88
+ [true, 16, 1, 1, [0, 1, 0, 1, 0]],
89
+ # Single failed request that escalates without logs being dropped with
90
+ # several entries.
91
+ [true, 13, 1, 2, [0, 1, 0, 0, 2]]
91
92
  ].each do |should_fail, code, request_count, entry_count, metric_values|
92
93
  setup_prometheus
93
94
  setup_logging_stubs(should_fail, code, 'SomeMessage') do
@@ -106,7 +107,8 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
106
107
  end
107
108
  end
108
109
  successful_requests_count, failed_requests_count,
109
- ingested_entries_count, dropped_entries_count = metric_values
110
+ ingested_entries_count, dropped_entries_count,
111
+ retried_entries_count = metric_values
110
112
  assert_prometheus_metric_value(:stackdriver_successful_requests_count,
111
113
  successful_requests_count, grpc: true)
112
114
  assert_prometheus_metric_value(:stackdriver_failed_requests_count,
@@ -116,6 +118,8 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
116
118
  ingested_entries_count)
117
119
  assert_prometheus_metric_value(:stackdriver_dropped_entries_count,
118
120
  dropped_entries_count)
121
+ assert_prometheus_metric_value(:stackdriver_retried_entries_count,
122
+ retried_entries_count, code: code)
119
123
  end
120
124
  end
121
125
 
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.8.pre.1
4
+ version: 0.6.8.pre.2
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-09-06 00:00:00.000000000 Z
12
+ date: 2017-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd