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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd01ed137f37018a18018778b7203c1e3c9ed2bc
|
4
|
+
data.tar.gz: 478756303d13c730f319b5eb3547d4a2af571332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a6bef237c7c06ea23fd77c0adc34625b370d3b170edbe3c9d2b2445ee9d1725454ba0752578adb320090111051eefabd4f6c5df2ecd2a9d1a061b8ed2c6e78
|
7
|
+
data.tar.gz: 8881fb329a39626cbd657dd6b7468c990beaee6f50a751f1fde937b3ab5c2661dea9e51a9dc5474653bc4803c686e18f92421ad5f91c2f0873c3d36ed7d313f6
|
data/Gemfile.lock
CHANGED
@@ -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.
|
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('
|
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['
|
131
|
+
@api_key = ENV['DD_API_KEY']
|
132
132
|
if @api_key == '' || @api_key.nil?
|
133
|
-
error_message = 'Unable to obtain api_key from
|
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
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
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:
|
275
|
-
source:
|
276
|
-
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
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
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
|
Binary file
|
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.
|
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
|