fluent-plugin-barito 0.1.13 → 0.1.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84669e65564859fa5fe631b76e71d9f830a23d66a524c5942d4300be7396c24
|
4
|
+
data.tar.gz: 60f1835917729abd12d00608f81c18aa063aee92925ca0246bfe720603d0c260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc7bde45ea4f7601f0a35ed06ab6f3342da74574b6e7adcc344081afe0479ee7d3f9532106cd0aaa070bb811f1623b81590ea5c71288c3231a3085af822834bd
|
7
|
+
data.tar.gz: 889dc1965589f3f9418163af70c14a2329a61692e7f5f25f7cc843cfc984e99365d1bcb94c3c56ad1064dff3dfd6153be2782e3c35741fba930d4b601cf34ff1
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-barito"
|
6
|
-
spec.version = "0.1.
|
6
|
+
spec.version = "0.1.14"
|
7
7
|
spec.authors = ["BaritoLog"]
|
8
8
|
spec.email = ["pushm0v.development@gmail.com", "iman.tung@gmail.com"]
|
9
9
|
|
@@ -37,15 +37,13 @@ module Fluent
|
|
37
37
|
|
38
38
|
next if url.nil? or secret.nil?
|
39
39
|
|
40
|
-
|
41
|
-
record.delete('kubernetes')
|
42
|
-
record.delete('docker')
|
43
|
-
|
40
|
+
record = clean_attribute(record)
|
44
41
|
trail = Fluent::Plugin::ClientTrail.new(true)
|
45
42
|
timber = Fluent::Plugin::TimberFactory::create_timber(tag, time, record, trail)
|
43
|
+
new_timber = merge_log_attribute(timber)
|
46
44
|
|
47
45
|
# Add kubernetes information
|
48
|
-
|
46
|
+
new_timber['k8s_metadata'] = {
|
49
47
|
'pod_name' => k8s_metadata['pod_name'],
|
50
48
|
'namespace_name' => k8s_metadata['namespace_name'],
|
51
49
|
'container_name' => k8s_metadata['container_name'],
|
@@ -54,7 +52,7 @@ module Fluent
|
|
54
52
|
|
55
53
|
header = {content_type: :json, 'X-App-Secret' => secret}
|
56
54
|
|
57
|
-
RestClient.post url,
|
55
|
+
RestClient.post url, new_timber.to_json, header
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -65,5 +63,26 @@ module Fluent
|
|
65
63
|
def application_secret(params)
|
66
64
|
params[LABEL_APP_SECRET]
|
67
65
|
end
|
66
|
+
|
67
|
+
def clean_attribute(record)
|
68
|
+
# Delete kubernetes & docker field
|
69
|
+
record.delete('kubernetes')
|
70
|
+
record.delete('docker')
|
71
|
+
record
|
72
|
+
end
|
73
|
+
|
74
|
+
def merge_log_attribute(record)
|
75
|
+
message_log = nil
|
76
|
+
begin
|
77
|
+
message_log = JSON.parse(record['log'])
|
78
|
+
rescue
|
79
|
+
end
|
80
|
+
|
81
|
+
if !message_log.nil?
|
82
|
+
return record.merge(message_log)
|
83
|
+
end
|
84
|
+
|
85
|
+
record
|
86
|
+
end
|
68
87
|
end
|
69
88
|
end
|
@@ -26,5 +26,30 @@ describe 'Fluent::BaritoK8sOutput' do
|
|
26
26
|
expect(secret).to eq 'some_secret'
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
|
+
describe '.merge_log_attribute' do
|
31
|
+
it do
|
32
|
+
out = Fluent::BaritoK8sOutput.new
|
33
|
+
|
34
|
+
record = { "log" => "{\"some_attr\":\"info\"}", "other_attr" => "other_value"}
|
35
|
+
new_record = out.merge_log_attribute(record)
|
36
|
+
|
37
|
+
expect(new_record['some_attr']).to eq("info")
|
38
|
+
expect(new_record['other_attr']).to eq("other_value")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.clean_attribute' do
|
43
|
+
it do
|
44
|
+
out = Fluent::BaritoK8sOutput.new
|
45
|
+
|
46
|
+
record = {"kubernetes" => {"some_attr" => "some_value"}, "docker" => "docker_value", "attr" => "some_value"}
|
47
|
+
new_record = out.clean_attribute(record)
|
48
|
+
|
49
|
+
expect(new_record['kubernetes']).to be_nil
|
50
|
+
expect(new_record['docker']).to be_nil
|
51
|
+
expect(new_record['attr']).to eq("some_value")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
30
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-barito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BaritoLog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|