fluent-plugin-google-cloud 0.7.15 → 0.7.16

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
  SHA256:
3
- metadata.gz: 7deed85b438bb17342217bdf9b4c849577217a70702005b8912f07e854e2b62f
4
- data.tar.gz: 37f6366b74c5f59d1a5ded992cb16d79eeb16ed61e7f99d50b28d68527e488f5
3
+ metadata.gz: cfb019175c35271448646b370774c129b48096dac9a1dfb5a1904776ba0af63c
4
+ data.tar.gz: 07ffca87bc262f3a29b964b47ccefd69551ad3b11384b54295f1270d101d4633
5
5
  SHA512:
6
- metadata.gz: 9ec2439d5df4db5196e11680d2d28da15a7602e234272536622bc24389c69c46361a07694b76dd77c2a7fb285c2bdfaf18153b9c0b692e99bc2c931d498042ba
7
- data.tar.gz: 0be1859cd6518819843caf5ab391e3e406f13a60d7c91672bcad79ecbd9242f45875bd1199a47758a6bfed8a957687c9d977771a07e0afe389ec7533bac55672
6
+ metadata.gz: f4f2584f87ab91bd87d75b7139555928e3d5daaa073170258a7125468a5a2b24bcce968b2f3120f13f8f6ef5328029c2a5ac6171fab0e0b2b8654eb3436f6941
7
+ data.tar.gz: 7d917d3ecbd2d946e8c712a2c686a5322465b3154fc2c5b889f87fa299b53dd17a5396509315d8cb89a40b55c8960dffe41995c342df01baa50cc3c1a287bc7d
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.7.15)
5
- fluentd (= 1.4.2)
6
- google-api-client (= 0.28.4)
7
- google-cloud-logging (= 1.6.0)
8
- google-protobuf (= 3.6.1)
9
- googleapis-common-protos (= 1.3.7)
10
- googleauth (= 0.8.1)
11
- grpc (= 1.14.2)
12
- json (= 2.1.0)
4
+ fluent-plugin-google-cloud (0.7.16)
5
+ fluentd (= 1.6.3)
6
+ google-api-client (= 0.30.8)
7
+ google-cloud-logging (= 1.6.6)
8
+ google-protobuf (= 3.9.0)
9
+ googleapis-common-protos (= 1.3.9)
10
+ googleauth (= 0.9.0)
11
+ grpc (= 1.22.0)
12
+ json (= 2.2.0)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
@@ -26,7 +26,7 @@ GEM
26
26
  dig_rb (1.0.1)
27
27
  faraday (0.15.4)
28
28
  multipart-post (>= 1.2, < 3)
29
- fluentd (1.4.2)
29
+ fluentd (1.6.3)
30
30
  cool.io (>= 1.4.5, < 2.0.0)
31
31
  dig_rb (~> 1.0.0)
32
32
  http_parser.rb (>= 0.5.1, < 0.7.0)
@@ -37,11 +37,11 @@ GEM
37
37
  tzinfo (~> 1.0)
38
38
  tzinfo-data (~> 1.0)
39
39
  yajl-ruby (~> 1.0)
40
- google-api-client (0.28.4)
40
+ google-api-client (0.30.8)
41
41
  addressable (~> 2.5, >= 2.5.1)
42
42
  googleauth (>= 0.5, < 0.10.0)
43
43
  httpclient (>= 2.8.1, < 3.0)
44
- mime-types (~> 3.0)
44
+ mini_mime (~> 1.0)
45
45
  representable (~> 3.0)
46
46
  retriable (>= 2.0, < 4.0)
47
47
  signet (~> 0.10)
@@ -49,10 +49,10 @@ GEM
49
49
  google-cloud-env (~> 1.0)
50
50
  google-cloud-env (1.2.0)
51
51
  faraday (~> 0.11)
52
- google-cloud-logging (1.6.0)
53
- concurrent-ruby (~> 1.0)
52
+ google-cloud-logging (1.6.6)
53
+ concurrent-ruby (~> 1.1)
54
54
  google-cloud-core (~> 1.2)
55
- google-gax (~> 1.3)
55
+ google-gax (~> 1.7)
56
56
  googleapis-common-protos-types (>= 1.0.2)
57
57
  stackdriver-core (~> 1.3)
58
58
  google-gax (1.7.0)
@@ -61,45 +61,43 @@ GEM
61
61
  googleauth (>= 0.6.2, < 0.10.0)
62
62
  grpc (>= 1.7.2, < 2.0)
63
63
  rly (~> 0.2.3)
64
- google-protobuf (3.6.1)
65
- googleapis-common-protos (1.3.7)
64
+ google-protobuf (3.9.0)
65
+ googleapis-common-protos (1.3.9)
66
66
  google-protobuf (~> 3.0)
67
67
  googleapis-common-protos-types (~> 1.0)
68
68
  grpc (~> 1.0)
69
69
  googleapis-common-protos-types (1.0.4)
70
70
  google-protobuf (~> 3.0)
71
- googleauth (0.8.1)
71
+ googleauth (0.9.0)
72
72
  faraday (~> 0.12)
73
73
  jwt (>= 1.4, < 3.0)
74
74
  memoist (~> 0.16)
75
75
  multi_json (~> 1.11)
76
76
  os (>= 0.9, < 2.0)
77
77
  signet (~> 0.7)
78
- grpc (1.14.2)
79
- google-protobuf (~> 3.1)
80
- googleapis-common-protos-types (~> 1.0.0)
81
- hashdiff (0.4.0)
78
+ grpc (1.22.0)
79
+ google-protobuf (~> 3.8)
80
+ googleapis-common-protos-types (~> 1.0)
81
+ hashdiff (1.0.0)
82
82
  http_parser.rb (0.6.0)
83
83
  httpclient (2.8.3)
84
- json (2.1.0)
84
+ json (2.2.0)
85
85
  jwt (2.2.1)
86
86
  memoist (0.16.0)
87
87
  metaclass (0.0.4)
88
- mime-types (3.2.2)
89
- mime-types-data (~> 3.2015)
90
- mime-types-data (3.2019.0331)
88
+ mini_mime (1.0.2)
91
89
  mocha (1.9.0)
92
90
  metaclass (~> 0.0.1)
93
- msgpack (1.3.0)
91
+ msgpack (1.3.1)
94
92
  multi_json (1.13.1)
95
93
  multipart-post (2.1.1)
96
94
  os (1.0.1)
97
95
  parser (2.6.3.0)
98
96
  ast (~> 2.4.0)
99
- power_assert (1.1.4)
97
+ power_assert (1.1.5)
100
98
  powerpack (0.1.2)
101
- prometheus-client (0.7.1)
102
- quantile (~> 0.2.0)
99
+ prometheus-client (0.9.0)
100
+ quantile (~> 0.2.1)
103
101
  public_suffix (3.1.1)
104
102
  quantile (0.2.1)
105
103
  rainbow (2.2.2)
@@ -139,10 +137,10 @@ GEM
139
137
  tzinfo (>= 1.0.0)
140
138
  uber (0.1.0)
141
139
  unicode-display_width (1.6.0)
142
- webmock (2.3.2)
140
+ webmock (3.6.2)
143
141
  addressable (>= 2.3.6)
144
142
  crack (>= 0.3.2)
145
- hashdiff
143
+ hashdiff (>= 0.4.0, < 2.0.0)
146
144
  yajl-ruby (1.4.1)
147
145
 
148
146
  PLATFORMS
@@ -150,12 +148,12 @@ PLATFORMS
150
148
 
151
149
  DEPENDENCIES
152
150
  fluent-plugin-google-cloud!
153
- mocha (~> 1.1)
154
- prometheus-client (~> 0.7.1)
155
- rake (~> 10.3)
156
- rubocop (~> 0.39.0)
157
- test-unit (~> 3.0)
158
- webmock (~> 2.3.1)
151
+ mocha (= 1.9.0)
152
+ prometheus-client (= 0.9.0)
153
+ rake (= 10.5.0)
154
+ rubocop (= 0.39.0)
155
+ test-unit (= 3.3.3)
156
+ webmock (= 3.6.2)
159
157
 
160
158
  BUNDLED WITH
161
159
  1.16.6
@@ -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.7.15'
13
+ gem.version = '0.7.16'
14
14
  gem.authors = ['Stackdriver Agents Team']
15
15
  gem.email = ['stackdriver-agents@google.com']
16
16
  gem.required_ruby_version = Gem::Requirement.new('>= 2.2')
@@ -19,19 +19,24 @@ eos
19
19
  gem.test_files = gem.files.grep(/^(test)/)
20
20
  gem.require_paths = ['lib']
21
21
 
22
- gem.add_runtime_dependency 'fluentd', '1.4.2'
23
- gem.add_runtime_dependency 'googleapis-common-protos', '1.3.7'
24
- gem.add_runtime_dependency 'googleauth', '0.8.1'
25
- gem.add_runtime_dependency 'google-api-client', '0.28.4'
26
- gem.add_runtime_dependency 'google-cloud-logging', '1.6.0'
27
- gem.add_runtime_dependency 'google-protobuf', '3.6.1'
28
- gem.add_runtime_dependency 'grpc', '1.14.2'
29
- gem.add_runtime_dependency 'json', '2.1.0'
22
+ gem.add_runtime_dependency 'fluentd', '1.6.3'
23
+ gem.add_runtime_dependency 'googleapis-common-protos', '1.3.9'
24
+ gem.add_runtime_dependency 'googleauth', '0.9.0'
25
+ gem.add_runtime_dependency 'google-api-client', '0.30.8'
26
+ gem.add_runtime_dependency 'google-cloud-logging', '1.6.6'
27
+ gem.add_runtime_dependency 'google-protobuf', '3.9.0'
28
+ gem.add_runtime_dependency 'grpc', '1.22.0'
29
+ gem.add_runtime_dependency 'json', '2.2.0'
30
30
 
31
- gem.add_development_dependency 'mocha', '~> 1.1'
32
- gem.add_development_dependency 'prometheus-client', '~> 0.7.1'
33
- gem.add_development_dependency 'rake', '~> 10.3'
34
- gem.add_development_dependency 'rubocop', '~> 0.39.0'
35
- gem.add_development_dependency 'test-unit', '~> 3.0'
36
- gem.add_development_dependency 'webmock', '~> 2.3.1'
31
+ gem.add_development_dependency 'mocha', '1.9.0'
32
+ gem.add_development_dependency 'prometheus-client', '0.9.0'
33
+ # TODO(qingling128): Upgrade rake to 11.0+ after the following issues are
34
+ # fixed because rake (11.0+) requires ALL variables to be explicitly
35
+ # initialized.
36
+ # https://github.com/googleapis/google-auth-library-ruby/issues/227
37
+ # https://github.com/farcaller/rly/issues/2
38
+ gem.add_development_dependency 'rake', '10.5.0'
39
+ gem.add_development_dependency 'rubocop', '0.39.0'
40
+ gem.add_development_dependency 'test-unit', '3.3.3'
41
+ gem.add_development_dependency 'webmock', '3.6.2'
37
42
  end
@@ -16,7 +16,7 @@ module Monitoring
16
16
  # Base class for the monitoring registry.
17
17
  class BaseMonitoringRegistry
18
18
  def counter(_name, _desc)
19
- _undefined
19
+ nil
20
20
  end
21
21
  end
22
22
 
@@ -48,6 +48,10 @@ module Monitoring
48
48
  PrometheusMonitoringRegistry
49
49
  }
50
50
 
51
+ def self.supports_monitoring_type(name)
52
+ @known_registry_types.key?(name)
53
+ end
54
+
51
55
  def self.create(name)
52
56
  (@known_registry_types[name] || BaseMonitoringRegistry).new
53
57
  end
@@ -36,6 +36,7 @@ module Google
36
36
  # Alias the has_key? method to have the same interface as a regular map.
37
37
  class Map
38
38
  alias key? has_key?
39
+ alias to_hash to_h
39
40
  end
40
41
  end
41
42
  end
@@ -460,6 +461,14 @@ module Fluent
460
461
  super
461
462
  # use the global logger
462
463
  @log = $log # rubocop:disable Style/GlobalVars
464
+
465
+ @failed_requests_count = nil
466
+ @successful_requests_count = nil
467
+ @dropped_entries_count = nil
468
+ @ingested_entries_count = nil
469
+ @retried_entries_count = nil
470
+
471
+ @ok_code = nil
463
472
  end
464
473
 
465
474
  def configure(conf)
@@ -491,6 +500,11 @@ module Fluent
491
500
  # If monitoring is enabled, register metrics in the default registry
492
501
  # and store metric objects for future use.
493
502
  if @enable_monitoring
503
+ unless Monitoring::MonitoringRegistryFactory.supports_monitoring_type(
504
+ @monitoring_type)
505
+ @log.warn "monitoring_type '#{@monitoring_type}' is unknown; "\
506
+ 'there will be no metrics'
507
+ end
494
508
  registry = Monitoring::MonitoringRegistryFactory.create @monitoring_type
495
509
  @successful_requests_count = registry.counter(
496
510
  :stackdriver_successful_requests_count,
@@ -592,7 +606,7 @@ module Fluent
592
606
  @statusz_port,
593
607
  bind: '127.0.0.1') do |data, conn|
594
608
  if data.split(' ')[1] == '/statusz'
595
- write_html_response(data, conn, 200, Statusz.response)
609
+ write_html_response(data, conn, 200, Statusz.response(self))
596
610
  else
597
611
  write_html_response(data, conn, 404, "Not found\n")
598
612
  end
@@ -624,8 +638,14 @@ module Fluent
624
638
  # Save the following fields if available, then clear them out to
625
639
  # allow for determining whether we should parse the log or message
626
640
  # field.
641
+ # This list should be in sync with
642
+ # https://cloud.google.com/logging/docs/agent/configuration#special-fields.
627
643
  preserved_keys = [
628
644
  'time',
645
+ 'timeNanos',
646
+ 'timestamp',
647
+ 'timestampNanos',
648
+ 'timestampSeconds',
629
649
  'severity',
630
650
  @http_request_key,
631
651
  @insert_id_key,
@@ -1031,7 +1051,7 @@ module Fluent
1031
1051
  end
1032
1052
 
1033
1053
  begin
1034
- open('http://' + METADATA_SERVICE_ADDR) do |f|
1054
+ open('http://' + METADATA_SERVICE_ADDR, proxy: false) do |f|
1035
1055
  if f.meta['metadata-flavor'] == 'Google'
1036
1056
  @log.info 'Detected GCE platform'
1037
1057
  return Platform::GCE
@@ -1054,7 +1074,8 @@ module Fluent
1054
1074
  @platform == Platform::GCE
1055
1075
  # See https://cloud.google.com/compute/docs/metadata
1056
1076
  open('http://' + METADATA_SERVICE_ADDR + '/computeMetadata/v1/' +
1057
- metadata_path, 'Metadata-Flavor' => 'Google', &:read)
1077
+ metadata_path, 'Metadata-Flavor' => 'Google', :proxy => false,
1078
+ &:read)
1058
1079
  end
1059
1080
 
1060
1081
  # EC2 Metadata server returns everything in one call. Store it after the
@@ -1065,7 +1086,7 @@ module Fluent
1065
1086
  unless @ec2_metadata
1066
1087
  # See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
1067
1088
  open('http://' + METADATA_SERVICE_ADDR +
1068
- '/latest/dynamic/instance-identity/document') do |f|
1089
+ '/latest/dynamic/instance-identity/document', proxy: false) do |f|
1069
1090
  contents = f.read
1070
1091
  @ec2_metadata = JSON.parse(contents)
1071
1092
  end
@@ -2242,7 +2263,6 @@ module Fluent
2242
2263
  def construct_error_details_map_grpc(gax_error)
2243
2264
  return {} unless @partial_success
2244
2265
  error_details_map = Hash.new { |h, k| h[k] = [] }
2245
-
2246
2266
  error_details = ensure_array(gax_error.status_details)
2247
2267
  raise JSON::ParserError, 'The error details are empty.' if
2248
2268
  error_details.empty?
@@ -2330,10 +2350,12 @@ module Fluent
2330
2350
  constructed_resource
2331
2351
  end
2332
2352
 
2353
+ # Convert the value to a Ruby array.
2333
2354
  def ensure_array(value)
2334
2355
  Array.try_convert(value) || (raise JSON::ParserError, value.class.to_s)
2335
2356
  end
2336
2357
 
2358
+ # Convert the value to a Ruby hash.
2337
2359
  def ensure_hash(value)
2338
2360
  Hash.try_convert(value) || (raise JSON::ParserError, value.class.to_s)
2339
2361
  end
@@ -12,20 +12,116 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require 'erb'
16
+
15
17
  # Module for collecting diagnostic information and formatting it as an
16
18
  # HTML page to serve on the /statusz endpoint.
17
19
  module Statusz
18
20
  module_function
19
21
 
20
- def response
21
- # TODO(davidbtucker): Add more status information here.
22
- [
23
- '<html>',
24
- '<body>',
25
- '<h1>Status</h1>',
26
- "<b>Command-line flags:</b> #{CGI.escapeHTML(ARGV.join(' '))}",
27
- '</body>',
28
- '</html>'
29
- ].join("\n") + "\n"
22
+ # Note: The plugin parameter is referenced in STATUSZ_TMPL.
23
+ def response(plugin)
24
+ uptime = Time.now - SERVER_START
25
+ uptime_str = format('%d hr %02d min %02d sec',
26
+ uptime / 3600,
27
+ (uptime / 60) % 60,
28
+ uptime % 60)
29
+ ERB.new(STATUSZ_TMPL).result(binding)
30
30
  end
31
31
  end
32
+
33
+ SERVER_START = Time.now
34
+
35
+ # Does not include the following deprecated config params:
36
+ # auth_method, private_key_email, private_key_passphrase, private_key_path
37
+ CONFIG_KEYS = %w(
38
+ adjust_invalid_timestamps
39
+ autoformat_stackdriver_trace
40
+ coerce_to_utf8
41
+ detect_json
42
+ detect_subservice
43
+ enable_metadata_agent
44
+ enable_monitoring
45
+ http_request_key
46
+ insert_id_key
47
+ k8s_cluster_location
48
+ k8s_cluster_name
49
+ kubernetes_tag_regexp
50
+ label_map
51
+ labels_key
52
+ labels
53
+ logging_api_url
54
+ metadata_agent_url
55
+ monitoring_type
56
+ non_utf8_replacement_string
57
+ operation_key
58
+ partial_success
59
+ project_id
60
+ require_valid_tags
61
+ source_location_key
62
+ span_id_key
63
+ split_logs_by_tag
64
+ statusz_port
65
+ subservice_name
66
+ trace_key
67
+ trace_sampled_key
68
+ use_aws_availability_zone
69
+ use_grpc
70
+ use_metadata_service
71
+ vm_id
72
+ vm_name
73
+ zone
74
+ ).freeze
75
+
76
+ # rubocop:disable LineLength
77
+ STATUSZ_TMPL = %(\
78
+ <!DOCTYPE html>
79
+ <html>
80
+ <head>
81
+ <title>Status for <%= File.basename($PROGRAM_NAME) %></title>
82
+ <style>
83
+ body {
84
+ font-family: sans-serif;
85
+ }
86
+ h1 {
87
+ clear: both;
88
+ width: 100%;
89
+ text-align: center;
90
+ font-size: 120%;
91
+ background: #eef;
92
+ }
93
+ .lefthand {
94
+ float: left;
95
+ width: 80%;
96
+ }
97
+ .righthand {
98
+ text-align: right;
99
+ }
100
+ td, th {
101
+ background-color: rgba(0, 0, 0, 0.05);
102
+ }
103
+ th {
104
+ text-align: left;
105
+ }
106
+ </style>
107
+ </head>
108
+
109
+ <body>
110
+ <h1>Status for <%= File.basename($PROGRAM_NAME) %></h1>
111
+
112
+ <div>
113
+ <div class="lefthand">
114
+ Started: <%= SERVER_START %><br>
115
+ Up <%= uptime_str %><br>
116
+ </div>
117
+ </div>
118
+
119
+ <h1>Parsed configuration</h1>
120
+
121
+ <table>
122
+ #{CONFIG_KEYS.map { |k| " <tr><th>#{k}</th><td><%= plugin.#{k} %></td></tr>" }.join("\n")}
123
+ </table>
124
+ </body>
125
+ </html>
126
+ ).freeze
127
+ # rubocop:enable LineLength