fluent-plugin-datadog-log 0.1.0.rc4 → 0.1.0.rc5

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: 158cd2fccb7054e6b940dc005a0eac7b7a358750
4
- data.tar.gz: d3a5bd069e6663ec704639d9303ee522484a364e
3
+ metadata.gz: cd01ed137f37018a18018778b7203c1e3c9ed2bc
4
+ data.tar.gz: 478756303d13c730f319b5eb3547d4a2af571332
5
5
  SHA512:
6
- metadata.gz: b416daef3f8c4336b837607dd8ba620173e5b017e5d03f4bc2df0ae999eaa275e2787c93152cff705e1e9e6805ab4549aacb0d885f608a87c7fc26f294c730bb
7
- data.tar.gz: a7ffe10ced889a307d77f563db0b829b0ce08730acee6bcd5af1152ab643db4ac24911e9a38ea4713660ed1ef7a8a9ef0384273f5766f0b6cefca8c94596b503
6
+ metadata.gz: 80a6bef237c7c06ea23fd77c0adc34625b370d3b170edbe3c9d2b2445ee9d1725454ba0752578adb320090111051eefabd4f6c5df2ecd2a9d1a061b8ed2c6e78
7
+ data.tar.gz: 8881fb329a39626cbd657dd6b7468c990beaee6f50a751f1fde937b3ab5c2661dea9e51a9dc5474653bc4803c686e18f92421ad5f91c2f0873c3d36ed7d313f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-datadog-log (0.1.0.rc4)
4
+ fluent-plugin-datadog-log (0.1.0.rc5)
5
5
  fluentd (~> 0.14)
6
6
  json (~> 1.8)
7
7
  net_tcp_client (~> 2.0.1)
@@ -8,7 +8,7 @@ eos
8
8
  gem.homepage = \
9
9
  'https://github.com/mumoshu/fluent-plugin-datadog-log'
10
10
  gem.license = 'Apache-2.0'
11
- gem.version = '0.1.0.rc4'
11
+ gem.version = '0.1.0.rc5'
12
12
  gem.authors = ['Yusuke KUOKA']
13
13
  gem.email = ['ykuoka@gmail.com']
14
14
  gem.required_ruby_version = Gem::Requirement.new('>= 2.0')
@@ -25,7 +25,7 @@ require_relative 'monitoring'
25
25
  module Fluent::Plugin
26
26
  # fluentd output plugin for the Datadog Log Intake API
27
27
  class DatadogOutput < ::Fluent::Plugin::Output
28
- Fluent::Plugin.register_output('datadog', self)
28
+ Fluent::Plugin.register_output('datadog_log', self)
29
29
 
30
30
  helpers :compat_parameters, :inject
31
31
 
@@ -128,9 +128,9 @@ module Fluent::Plugin
128
128
  super
129
129
 
130
130
  if @api_key.size == 0
131
- @api_key = ENV['DD_LOG_API_KEY']
131
+ @api_key = ENV['DD_API_KEY']
132
132
  if @api_key == '' || @api_key.nil?
133
- error_message = 'Unable to obtain api_key from DD_LOG_API_KEY'
133
+ error_message = 'Unable to obtain api_key from DD_API_KEY'
134
134
  fail Fluent::ConfigError, error_message
135
135
  end
136
136
  end
@@ -249,10 +249,26 @@ module Fluent::Plugin
249
249
  tags << "#{tag_key}=#{kube[json_key]}" if kube.key? json_key
250
250
  end
251
251
 
252
- if kube.key? 'labels'
253
- labels = kube['labels']
254
- labels.each do |k, v|
255
- tags << "kube_#{k}=#{v}"
252
+ kube_labels = kube['labels']
253
+ unless kube_labels.nil?
254
+ kube_labels.each do |k, v|
255
+ k2 = k.dup
256
+ k2.gsub!(/[\,\.]/, '_')
257
+ k2.gsub!(%r{/}, '-')
258
+ tags << "kube_#{k2}=#{v}"
259
+ end
260
+ end
261
+
262
+ if kube.key? 'annotations'
263
+ annotations = kube['annotations']
264
+ created_by_str = annotations['kubernetes.io/created-by']
265
+ unless created_by_str.nil?
266
+ created_by = JSON.parse(created_by_str)
267
+ ref = created_by['reference'] unless created_by.nil?
268
+ kind = ref['kind'] unless ref.nil?
269
+ name = ref['name'] unless ref.nil?
270
+ kind = kind.downcase unless kind.nil?
271
+ tags << "kube_#{kind}=#{name}" if !kind.nil? && !name.nil?
256
272
  end
257
273
  end
258
274
 
@@ -264,6 +280,17 @@ module Fluent::Plugin
264
280
 
265
281
  tags.concat(@default_tags)
266
282
 
283
+ unless kube_labels.nil?
284
+ service = kube_labels['app'] ||
285
+ kube_labels['k8s-app']
286
+ end
287
+ source = kube['pod_name']
288
+ source_category = kube['container_name']
289
+
290
+ service = @service if service.nil?
291
+ source = @source if source.nil?
292
+ source_category = @source_category if source_category.nil?
293
+
267
294
  datetime = Time.at(Fluent::EventTime.new(time).to_r).utc.to_datetime
268
295
 
269
296
  payload =
@@ -271,9 +298,9 @@ module Fluent::Plugin
271
298
  logset: @logset,
272
299
  msg: msg,
273
300
  datetime: datetime,
274
- service: @service,
275
- source: @source,
276
- source_category: @source_category,
301
+ service: service,
302
+ source: source,
303
+ source_category: source_category,
277
304
  tags: tags
278
305
  )
279
306
 
@@ -291,11 +318,17 @@ module Fluent::Plugin
291
318
 
292
319
  rescue => error
293
320
  increment_failed_requests_count
294
- increment_retried_entries_count(entries_count)
295
- # RPC cancelled, so retry via re-raising the error.
296
- @log.debug "Retrying #{entries_count} log message(s) later.",
297
- error: error.to_s
298
- raise error
321
+ if entries_count.nil?
322
+ increment_dropped_entries_count(1)
323
+ @log.error 'Not retrying a log message later',
324
+ error: error.to_s
325
+ else
326
+ increment_retried_entries_count(entries_count)
327
+ # RPC cancelled, so retry via re-raising the error.
328
+ @log.debug "Retrying #{entries_count} log message(s) later.",
329
+ error: error.to_s
330
+ raise error
331
+ end
299
332
  end
300
333
  end
301
334
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-datadog-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc4
4
+ version: 0.1.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke KUOKA
@@ -162,6 +162,7 @@ files:
162
162
  - pkg/fluent-plugin-datadog-log-0.1.0.rc1.gem
163
163
  - pkg/fluent-plugin-datadog-log-0.1.0.rc2.gem
164
164
  - pkg/fluent-plugin-datadog-log-0.1.0.rc3.gem
165
+ - pkg/fluent-plugin-datadog-log-0.1.0.rc4.gem
165
166
  - test/helper.rb
166
167
  - test/plugin/base_test.rb
167
168
  - test/plugin/constants.rb