fluent-plugin-google-cloud 0.4.12 → 0.4.13

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.
@@ -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.4.12'
13
+ gem.version = '0.4.13'
14
14
  gem.authors = ['Todd Derr', 'Alex Robinson']
15
15
  gem.email = ['salty@google.com']
16
16
 
@@ -160,7 +160,7 @@ module Fluent
160
160
  end
161
161
 
162
162
  @cloudfunctions_tag_regexp =
163
- /\.(?<function_name>[^.]+)(?:\.\d+)?-[^-]+_default_worker$/
163
+ /\.(?<encoded_function_name>.+)\.\d+-[^-]+_default_worker$/
164
164
  @cloudfunctions_log_regexp = /^
165
165
  (?:\[(?<severity>.)\])?
166
166
  \[(?<timestamp>.{24})\]
@@ -313,18 +313,6 @@ module Fluent
313
313
  'commonLabels' => @common_labels,
314
314
  'entries' => []
315
315
  }
316
- if @service_name == CONTAINER_SERVICE && @compiled_kubernetes_tag_regexp
317
- # Container logs in Kubernetes are tagged based on where they came
318
- # from, so we can extract useful metadata from the tag.
319
- # Do this here to avoid having to repeat it for each record.
320
- match_data = @compiled_kubernetes_tag_regexp.match(tag)
321
- if match_data
322
- labels = write_log_entries_request['commonLabels']
323
- %w(namespace_name pod_name container_name).each do |field|
324
- labels["#{CONTAINER_SERVICE}/#{field}"] = match_data[field]
325
- end
326
- end
327
- end
328
316
  if @running_cloudfunctions
329
317
  # If the current group of entries is coming from a Cloud Functions
330
318
  # function, the function name can be extracted from the tag.
@@ -336,13 +324,26 @@ module Fluent
336
324
  labels = write_log_entries_request['commonLabels']
337
325
  labels["#{CLOUDFUNCTIONS_SERVICE}/region"] = @gcf_region
338
326
  labels["#{CLOUDFUNCTIONS_SERVICE}/function_name"] =
339
- match_data['function_name']
327
+ decode_cloudfunctions_function_name(
328
+ match_data['encoded_function_name'])
340
329
  else
341
330
  # Other logs are considered as coming from the Container Engine
342
331
  # service.
343
332
  @service_name = CONTAINER_SERVICE
344
333
  end
345
334
  end
335
+ if @service_name == CONTAINER_SERVICE && @compiled_kubernetes_tag_regexp
336
+ # Container logs in Kubernetes are tagged based on where they came
337
+ # from, so we can extract useful metadata from the tag.
338
+ # Do this here to avoid having to repeat it for each record.
339
+ match_data = @compiled_kubernetes_tag_regexp.match(tag)
340
+ if match_data
341
+ labels = write_log_entries_request['commonLabels']
342
+ %w(namespace_name pod_name container_name).each do |field|
343
+ labels["#{CONTAINER_SERVICE}/#{field}"] = match_data[field]
344
+ end
345
+ end
346
+ end
346
347
  is_container_json = nil
347
348
  arr.each do |time, record|
348
349
  next unless record.is_a?(Hash)
@@ -678,7 +679,8 @@ module Fluent
678
679
  'C' => 'CRITICAL',
679
680
  'A' => 'ALERT',
680
681
  # other misc. translations.
681
- 'ERR' => 'ERROR'
682
+ 'ERR' => 'ERROR',
683
+ 'F' => 'CRITICAL'
682
684
  }
683
685
 
684
686
  def parse_severity(severity_str)
@@ -714,6 +716,11 @@ module Fluent
714
716
  'DEFAULT'
715
717
  end
716
718
 
719
+ def decode_cloudfunctions_function_name(function_name)
720
+ function_name.gsub(/c\.[a-z]/) { |s| s.upcase[-1] }
721
+ .gsub('u.u', '_').gsub('d.d', '$').gsub('a.a', '@').gsub('p.p', '.')
722
+ end
723
+
717
724
  # Requires that record has a 'kubernetes' field.
718
725
  def handle_container_metadata(record, entry)
719
726
  fields = %w(namespace_id namespace_name pod_id pod_name container_name)
@@ -722,7 +729,7 @@ module Fluent
722
729
  "#{CONTAINER_SERVICE}/#{field}")
723
730
  end
724
731
  # Prepend label/ to all user-defined labels' keys.
725
- if record.key?('labels')
732
+ if record['kubernetes'].key?('labels')
726
733
  record['kubernetes']['labels'].each do |key, value|
727
734
  entry['metadata']['labels']["label/#{key}"] = value
728
735
  end
@@ -780,7 +787,7 @@ module Fluent
780
787
  def init_api_client
781
788
  @client = Google::APIClient.new(
782
789
  application_name: 'Fluentd Google Cloud Logging plugin',
783
- application_version: '0.4.12',
790
+ application_version: '0.4.13',
784
791
  retries: 1)
785
792
 
786
793
  if @auth_method == 'private_key'
@@ -67,15 +67,17 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
67
67
  CONTAINER_POD_ID = 'cad3c3c4-4b9c-11e5-9d81-42010af0194c'
68
68
  CONTAINER_POD_NAME = 'redis-master-c0l82.foo.bar'
69
69
  CONTAINER_CONTAINER_NAME = 'redis'
70
+ CONTAINER_LABEL_KEY = 'component'
71
+ CONTAINER_LABEL_VALUE = 'redis-component'
70
72
  CONTAINER_STREAM = 'stdout'
71
73
 
72
74
  # Cloud Functions specific labels
73
- CLOUDFUNCTIONS_FUNCTION_NAME = 'function-1'
75
+ CLOUDFUNCTIONS_FUNCTION_NAME = '$My_Function.Name-@1'
74
76
  CLOUDFUNCTIONS_REGION = 'us-central1'
75
77
  CLOUDFUNCTIONS_EXECUTION_ID = '123-0'
76
78
  CLOUDFUNCTIONS_CLUSTER_NAME = 'cluster-1'
77
79
  CLOUDFUNCTIONS_NAMESPACE_NAME = 'default'
78
- CLOUDFUNCTIONS_POD_NAME = "#{CLOUDFUNCTIONS_FUNCTION_NAME}.987-c0l82"
80
+ CLOUDFUNCTIONS_POD_NAME = 'd.dc.myu.uc.functionp.pc.name-a.a1.987-c0l82'
79
81
  CLOUDFUNCTIONS_CONTAINER_NAME = 'worker'
80
82
 
81
83
  # Parameters used for authentication
@@ -207,6 +209,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
207
209
  "#{CONTAINER_SERVICE_NAME}/pod_id" => CONTAINER_POD_ID,
208
210
  "#{CONTAINER_SERVICE_NAME}/container_name" => CONTAINER_CONTAINER_NAME,
209
211
  "#{CONTAINER_SERVICE_NAME}/stream" => CONTAINER_STREAM,
212
+ "label/#{CONTAINER_LABEL_KEY}" => CONTAINER_LABEL_VALUE,
210
213
  "#{COMPUTE_SERVICE_NAME}/resource_type" => 'instance',
211
214
  "#{COMPUTE_SERVICE_NAME}/resource_id" => VM_ID,
212
215
  "#{COMPUTE_SERVICE_NAME}/resource_name" => HOSTNAME
@@ -248,11 +251,6 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
248
251
  "#{CLOUDFUNCTIONS_SERVICE_NAME}/region" => CLOUDFUNCTIONS_REGION,
249
252
  "#{CONTAINER_SERVICE_NAME}/instance_id" => VM_ID,
250
253
  "#{CONTAINER_SERVICE_NAME}/cluster_name" => CLOUDFUNCTIONS_CLUSTER_NAME,
251
- "#{CONTAINER_SERVICE_NAME}/namespace_name" =>
252
- CLOUDFUNCTIONS_NAMESPACE_NAME,
253
- "#{CONTAINER_SERVICE_NAME}/pod_name" => CLOUDFUNCTIONS_POD_NAME,
254
- "#{CONTAINER_SERVICE_NAME}/container_name" =>
255
- CLOUDFUNCTIONS_CONTAINER_NAME,
256
254
  "#{COMPUTE_SERVICE_NAME}/resource_type" => 'instance',
257
255
  "#{COMPUTE_SERVICE_NAME}/resource_id" => VM_ID,
258
256
  "#{COMPUTE_SERVICE_NAME}/resource_name" => HOSTNAME
@@ -270,11 +268,6 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
270
268
  "#{CLOUDFUNCTIONS_SERVICE_NAME}/region" => CLOUDFUNCTIONS_REGION,
271
269
  "#{CONTAINER_SERVICE_NAME}/instance_id" => VM_ID,
272
270
  "#{CONTAINER_SERVICE_NAME}/cluster_name" => CLOUDFUNCTIONS_CLUSTER_NAME,
273
- "#{CONTAINER_SERVICE_NAME}/namespace_name" =>
274
- CLOUDFUNCTIONS_NAMESPACE_NAME,
275
- "#{CONTAINER_SERVICE_NAME}/pod_name" => CLOUDFUNCTIONS_POD_NAME,
276
- "#{CONTAINER_SERVICE_NAME}/container_name" =>
277
- CLOUDFUNCTIONS_CONTAINER_NAME,
278
271
  "#{COMPUTE_SERVICE_NAME}/resource_type" => 'instance',
279
272
  "#{COMPUTE_SERVICE_NAME}/resource_id" => VM_ID,
280
273
  "#{COMPUTE_SERVICE_NAME}/resource_name" => HOSTNAME
@@ -1261,7 +1254,10 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
1261
1254
  namespace_name: CONTAINER_NAMESPACE_NAME,
1262
1255
  pod_id: CONTAINER_POD_ID,
1263
1256
  pod_name: CONTAINER_POD_NAME,
1264
- container_name: CONTAINER_CONTAINER_NAME
1257
+ container_name: CONTAINER_CONTAINER_NAME,
1258
+ labels: {
1259
+ CONTAINER_LABEL_KEY => CONTAINER_LABEL_VALUE
1260
+ }
1265
1261
  }
1266
1262
  }
1267
1263
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Todd Derr
@@ -9,101 +10,114 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-11-11 00:00:00.000000000 Z
13
+ date: 2015-12-17 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: fluentd
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - "~>"
20
+ - - ~>
19
21
  - !ruby/object:Gem::Version
20
22
  version: '0.10'
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
- - - "~>"
28
+ - - ~>
26
29
  - !ruby/object:Gem::Version
27
30
  version: '0.10'
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: google-api-client
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
- - - ">="
36
+ - - ! '>='
33
37
  - !ruby/object:Gem::Version
34
38
  version: 0.8.6
35
- - - "<="
39
+ - - <=
36
40
  - !ruby/object:Gem::Version
37
41
  version: '0.9'
38
42
  type: :runtime
39
43
  prerelease: false
40
44
  version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
41
46
  requirements:
42
- - - ">="
47
+ - - ! '>='
43
48
  - !ruby/object:Gem::Version
44
49
  version: 0.8.6
45
- - - "<="
50
+ - - <=
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0.9'
48
53
  - !ruby/object:Gem::Dependency
49
54
  name: googleauth
50
55
  requirement: !ruby/object:Gem::Requirement
56
+ none: false
51
57
  requirements:
52
- - - "~>"
58
+ - - ~>
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0.4'
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
58
65
  requirements:
59
- - - "~>"
66
+ - - ~>
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0.4'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: json
64
71
  requirement: !ruby/object:Gem::Requirement
72
+ none: false
65
73
  requirements:
66
- - - "~>"
74
+ - - ~>
67
75
  - !ruby/object:Gem::Version
68
76
  version: '1.8'
69
77
  type: :runtime
70
78
  prerelease: false
71
79
  version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
72
81
  requirements:
73
- - - "~>"
82
+ - - ~>
74
83
  - !ruby/object:Gem::Version
75
84
  version: '1.8'
76
85
  - !ruby/object:Gem::Dependency
77
86
  name: mocha
78
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
79
89
  requirements:
80
- - - "~>"
90
+ - - ~>
81
91
  - !ruby/object:Gem::Version
82
92
  version: '1.1'
83
93
  type: :development
84
94
  prerelease: false
85
95
  version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
86
97
  requirements:
87
- - - "~>"
98
+ - - ~>
88
99
  - !ruby/object:Gem::Version
89
100
  version: '1.1'
90
101
  - !ruby/object:Gem::Dependency
91
102
  name: rake
92
103
  requirement: !ruby/object:Gem::Requirement
104
+ none: false
93
105
  requirements:
94
- - - "~>"
106
+ - - ~>
95
107
  - !ruby/object:Gem::Version
96
108
  version: '10.3'
97
109
  type: :development
98
110
  prerelease: false
99
111
  version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
100
113
  requirements:
101
- - - "~>"
114
+ - - ~>
102
115
  - !ruby/object:Gem::Version
103
116
  version: '10.3'
104
117
  - !ruby/object:Gem::Dependency
105
118
  name: rubocop
106
119
  requirement: !ruby/object:Gem::Requirement
120
+ none: false
107
121
  requirements:
108
122
  - - '='
109
123
  - !ruby/object:Gem::Version
@@ -111,6 +125,7 @@ dependencies:
111
125
  type: :development
112
126
  prerelease: false
113
127
  version_requirements: !ruby/object:Gem::Requirement
128
+ none: false
114
129
  requirements:
115
130
  - - '='
116
131
  - !ruby/object:Gem::Version
@@ -118,79 +133,83 @@ dependencies:
118
133
  - !ruby/object:Gem::Dependency
119
134
  name: webmock
120
135
  requirement: !ruby/object:Gem::Requirement
136
+ none: false
121
137
  requirements:
122
- - - "~>"
138
+ - - ~>
123
139
  - !ruby/object:Gem::Version
124
140
  version: '1.17'
125
141
  type: :development
126
142
  prerelease: false
127
143
  version_requirements: !ruby/object:Gem::Requirement
144
+ none: false
128
145
  requirements:
129
- - - "~>"
146
+ - - ~>
130
147
  - !ruby/object:Gem::Version
131
148
  version: '1.17'
132
149
  - !ruby/object:Gem::Dependency
133
150
  name: test-unit
134
151
  requirement: !ruby/object:Gem::Requirement
152
+ none: false
135
153
  requirements:
136
- - - "~>"
154
+ - - ~>
137
155
  - !ruby/object:Gem::Version
138
156
  version: '3.0'
139
157
  type: :development
140
158
  prerelease: false
141
159
  version_requirements: !ruby/object:Gem::Requirement
160
+ none: false
142
161
  requirements:
143
- - - "~>"
162
+ - - ~>
144
163
  - !ruby/object:Gem::Version
145
164
  version: '3.0'
146
- description: |2
147
- Fluentd output plugin for the Google Cloud Logging API, which will make
148
- logs viewable in the Developer Console's log viewer and can optionally
149
- store them in Google Cloud Storage and/or BigQuery.
150
- This is an official Google Ruby gem.
165
+ description: ! " Fluentd output plugin for the Google Cloud Logging API, which will
166
+ make\n logs viewable in the Developer Console's log viewer and can optionally\n
167
+ \ store them in Google Cloud Storage and/or BigQuery.\n This is an official Google
168
+ Ruby gem.\n"
151
169
  email:
152
170
  - salty@google.com
153
171
  executables: []
154
172
  extensions: []
155
173
  extra_rdoc_files: []
156
174
  files:
157
- - CONTRIBUTING
158
- - Gemfile
159
- - Gemfile.lock
160
- - LICENSE
161
- - README.rdoc
162
- - Rakefile
163
- - fluent-plugin-google-cloud.gemspec
164
- - lib/fluent/plugin/out_google_cloud.rb
165
175
  - test/helper.rb
166
176
  - test/plugin/data/c31e573fd7f62ed495c9ca3821a5a85cb036dee1-privatekey.p12
167
177
  - test/plugin/data/credentials.json
168
178
  - test/plugin/data/iam-credentials.json
169
179
  - test/plugin/data/invalid_credentials.json
170
180
  - test/plugin/test_out_google_cloud.rb
181
+ - LICENSE
182
+ - Rakefile
183
+ - fluent-plugin-google-cloud.gemspec
184
+ - lib/fluent/plugin/out_google_cloud.rb
185
+ - CONTRIBUTING
186
+ - Gemfile.lock
187
+ - Gemfile
188
+ - README.rdoc
171
189
  homepage: https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud
172
190
  licenses:
173
191
  - Apache 2.0
174
- metadata: {}
175
192
  post_install_message:
176
193
  rdoc_options: []
177
194
  require_paths:
178
195
  - lib
179
196
  required_ruby_version: !ruby/object:Gem::Requirement
197
+ none: false
180
198
  requirements:
181
- - - ">="
199
+ - - ! '>='
182
200
  - !ruby/object:Gem::Version
183
201
  version: '0'
184
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
+ none: false
185
204
  requirements:
186
- - - ">="
205
+ - - ! '>='
187
206
  - !ruby/object:Gem::Version
188
207
  version: '0'
189
208
  requirements: []
190
209
  rubyforge_project:
191
- rubygems_version: 2.4.3
210
+ rubygems_version: 1.8.23
192
211
  signing_key:
193
- specification_version: 4
212
+ specification_version: 3
194
213
  summary: fluentd output plugin for the Google Cloud Logging API
195
214
  test_files:
196
215
  - test/helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1b7271a0228faf66d2353c964baa5c62a5ea4c07
4
- data.tar.gz: 80bbb3c3317d2700a746a3dc26d341fc24157af8
5
- SHA512:
6
- metadata.gz: 7f952cb04e042f81d68c3fb6496b5baabf9c2f64ec9adfe4b1ad874c0c829e8c8126133907762066d0867636311fc47b1d011c485089096cc99f8171eb29c2b5
7
- data.tar.gz: f10c6a9a326f7756cca26ca377ac002cdf45b712979f537d8e4873bf0b419d00fd2c464e15f9d73b294684af69db02ba78a80078204791fd97eca146f4f2d18f