fluent-plugin-google-cloud 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- 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 +33 -0
- data/lib/fluent/plugin/statusz.rb +31 -0
- data/test/plugin/constants.rb +1 -0
- data/test/plugin/test_out_google_cloud.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11e7c3f24960a167f14a79ccd2c0252309edcea31cd16ad7f10fa19ebfe9d186
|
4
|
+
data.tar.gz: 7e5f63454446b63abb2b5052c61d2d6a05d9c0f4b5b365fa77cb7b09884aa9c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2394c4f1c83bf050e5350878add926227554162d47a1d3223daf64535a676e67acd7a22c7c2276a2ff407d478957f59463d4c9b65085bc470fb04a2d9659f926
|
7
|
+
data.tar.gz: 44d03991a7175721775dfbaa7870ce33b3f4861e0f696c12ce946d829d28a7aef18fc5ace6b196a027dfe7e2225c696aea27cbc38d0b577d5511e6c611af803f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-google-cloud (0.7.
|
4
|
+
fluent-plugin-google-cloud (0.7.8)
|
5
5
|
fluentd (= 1.2.5)
|
6
6
|
google-api-client (= 0.28.4)
|
7
7
|
google-cloud-logging (= 1.6.0)
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
public_suffix (>= 2.0.2, < 4.0)
|
19
19
|
ast (2.4.0)
|
20
20
|
concurrent-ruby (1.1.5)
|
21
|
-
cool.io (1.5.
|
21
|
+
cool.io (1.5.4)
|
22
22
|
crack (0.4.3)
|
23
23
|
safe_yaml (~> 1.0.0)
|
24
24
|
declarative (0.0.10)
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
google-protobuf (~> 3.0)
|
67
67
|
googleapis-common-protos-types (~> 1.0)
|
68
68
|
grpc (~> 1.0)
|
69
|
-
googleapis-common-protos-types (1.0.
|
69
|
+
googleapis-common-protos-types (1.0.4)
|
70
70
|
google-protobuf (~> 3.0)
|
71
71
|
googleauth (0.6.6)
|
72
72
|
faraday (~> 0.12)
|
@@ -87,7 +87,7 @@ GEM
|
|
87
87
|
metaclass (0.0.4)
|
88
88
|
mime-types (3.2.2)
|
89
89
|
mime-types-data (~> 3.2015)
|
90
|
-
mime-types-data (3.
|
90
|
+
mime-types-data (3.2019.0331)
|
91
91
|
mocha (1.8.0)
|
92
92
|
metaclass (~> 0.0.1)
|
93
93
|
msgpack (1.2.9)
|
@@ -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.
|
13
|
+
gem.version = '0.7.8'
|
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')
|
@@ -11,6 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
+
require 'cgi'
|
14
15
|
require 'erb'
|
15
16
|
require 'grpc'
|
16
17
|
require 'json'
|
@@ -28,6 +29,7 @@ require 'google/logging/v2/log_entry_pb'
|
|
28
29
|
require 'googleauth'
|
29
30
|
|
30
31
|
require_relative 'monitoring'
|
32
|
+
require_relative 'statusz'
|
31
33
|
|
32
34
|
module Google
|
33
35
|
module Protobuf
|
@@ -241,6 +243,8 @@ module Fluent
|
|
241
243
|
|
242
244
|
Fluent::Plugin.register_output('google_cloud', self)
|
243
245
|
|
246
|
+
helpers :server
|
247
|
+
|
244
248
|
PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'.freeze
|
245
249
|
|
246
250
|
PLUGIN_VERSION = begin
|
@@ -441,6 +445,11 @@ module Fluent
|
|
441
445
|
# LogEntry.trace.
|
442
446
|
config_param :autoformat_stackdriver_trace, :bool, :default => true
|
443
447
|
|
448
|
+
# Port for web server that exposes a /statusz endpoint with
|
449
|
+
# diagnostic information in HTML format. If the value is 0,
|
450
|
+
# the server is not created.
|
451
|
+
config_param :statusz_port, :integer, :default => 0
|
452
|
+
|
444
453
|
# rubocop:enable Style/HashSyntax
|
445
454
|
|
446
455
|
# TODO: Add a log_name config option rather than just using the tag?
|
@@ -594,6 +603,19 @@ module Fluent
|
|
594
603
|
init_api_client
|
595
604
|
@successful_call = false
|
596
605
|
@timenanos_warning = false
|
606
|
+
|
607
|
+
if @statusz_port > 0
|
608
|
+
@log.info "Starting statusz server on port #{@statusz_port}"
|
609
|
+
server_create(:out_google_cloud_statusz,
|
610
|
+
@statusz_port,
|
611
|
+
bind: '127.0.0.1') do |data, conn|
|
612
|
+
if data.split(' ')[1] == '/statusz'
|
613
|
+
write_html_response(data, conn, 200, Statusz.response)
|
614
|
+
else
|
615
|
+
write_html_response(data, conn, 404, "Not found\n")
|
616
|
+
end
|
617
|
+
end
|
618
|
+
end
|
597
619
|
end
|
598
620
|
|
599
621
|
def shutdown
|
@@ -729,6 +751,17 @@ module Fluent
|
|
729
751
|
|
730
752
|
private
|
731
753
|
|
754
|
+
def write_html_response(data, conn, code, response)
|
755
|
+
@log.info "#{conn.remote_host} - - " \
|
756
|
+
"#{Time.now.strftime('%d/%b/%Y:%H:%M:%S %z')} " \
|
757
|
+
"\"#{data.lines.first.strip}\" #{code} #{response.bytesize}"
|
758
|
+
conn.write "HTTP/1.1 #{code}\r\n"
|
759
|
+
conn.write "Content-Type: text/html\r\n"
|
760
|
+
conn.write "Content-Length: #{response.bytesize}\r\n"
|
761
|
+
conn.write "\r\n"
|
762
|
+
conn.write response
|
763
|
+
end
|
764
|
+
|
732
765
|
def compute_trace(trace)
|
733
766
|
return trace unless @autoformat_stackdriver_trace &&
|
734
767
|
STACKDRIVER_TRACE_ID_REGEXP.match(trace)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright 2019 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# Module for collecting diagnostic information and formatting it as an
|
16
|
+
# HTML page to serve on the /statusz endpoint.
|
17
|
+
module Statusz
|
18
|
+
module_function
|
19
|
+
|
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"
|
30
|
+
end
|
31
|
+
end
|
data/test/plugin/constants.rb
CHANGED
@@ -12,12 +12,16 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
require 'fluent/test/startup_shutdown'
|
16
|
+
require 'net/http'
|
17
|
+
|
15
18
|
require_relative 'base_test'
|
16
19
|
require_relative 'test_driver'
|
17
20
|
|
18
21
|
# Unit tests for Google Cloud Logging plugin
|
19
22
|
class GoogleCloudOutputTest < Test::Unit::TestCase
|
20
23
|
include BaseTest
|
24
|
+
extend Fluent::Test::StartupShutdown
|
21
25
|
|
22
26
|
def test_configure_use_grpc
|
23
27
|
setup_gce_metadata_stubs
|
@@ -330,6 +334,18 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
330
334
|
end
|
331
335
|
end
|
332
336
|
|
337
|
+
def test_statusz_endpoint
|
338
|
+
setup_gce_metadata_stubs
|
339
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
340
|
+
# TODO(davidbtucker): Consider searching for an unused port
|
341
|
+
# instead of hardcoding a constant here.
|
342
|
+
d = create_driver('statusz_port 5678')
|
343
|
+
d.run do
|
344
|
+
assert_match Regexp.new('.*<h1>Status</h1>.*'),
|
345
|
+
Net::HTTP.get('127.0.0.1', '/statusz', 5678)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
333
349
|
private
|
334
350
|
|
335
351
|
WRITE_LOG_ENTRIES_URI =
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-google-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stackdriver Agents Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/fluent/plugin/filter_add_insert_ids.rb
|
229
229
|
- lib/fluent/plugin/monitoring.rb
|
230
230
|
- lib/fluent/plugin/out_google_cloud.rb
|
231
|
+
- lib/fluent/plugin/statusz.rb
|
231
232
|
- test/helper.rb
|
232
233
|
- test/plugin/base_test.rb
|
233
234
|
- test/plugin/constants.rb
|