fluent-plugin-barito 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/fluent-plugin-barito.gemspec +1 -1
- data/lib/fluent/plugin/out_barito.rb +26 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e95e18ae1e0e0b7d671f769d1dfb007faad8e9
|
4
|
+
data.tar.gz: 89b169bb424effbf3083bd9bdf498c7a7471df9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f598318664a9b9d02403e29212a6e55626e17ba8688573872a2e5773f528b32ce6982eb1194746d89eeaee81e92d5e343bc2308f446fcc54c251fe12aad8749
|
7
|
+
data.tar.gz: '0052769ee449f19df1369bb89a17c5064a17d409b2a67a7fae76b54b054117460235397b084d795514469fe2485e8e732ad4c12a461e1ee124d4430c8f5de7e7'
|
@@ -3,10 +3,15 @@ require 'rest-client'
|
|
3
3
|
|
4
4
|
module Fluent
|
5
5
|
class BaritoOutput < BufferedOutput
|
6
|
+
|
7
|
+
TIMESTAMP_FIELD = "@timestamp"
|
8
|
+
|
6
9
|
Fluent::Plugin.register_output("barito", self)
|
7
10
|
|
8
11
|
config_param :use_https, :bool, :default => false
|
9
12
|
config_param :use_kubernetes, :bool, :default => false
|
13
|
+
|
14
|
+
config_param :application_secret, :string, :default => ''
|
10
15
|
config_param :stream_id, :string, :default => ''
|
11
16
|
config_param :store_id, :string, :default => ''
|
12
17
|
config_param :client_id, :string, :default => ''
|
@@ -14,6 +19,8 @@ module Fluent
|
|
14
19
|
config_param :produce_host, :string, :default => ''
|
15
20
|
config_param :produce_port, :string, :default => ''
|
16
21
|
config_param :produce_topic, :string, :default => ''
|
22
|
+
|
23
|
+
config_param :produce_url, :string, :default => ''
|
17
24
|
|
18
25
|
def start
|
19
26
|
super
|
@@ -21,7 +28,7 @@ module Fluent
|
|
21
28
|
end
|
22
29
|
|
23
30
|
def send_message(url, message)
|
24
|
-
RestClient.post url, message, {content_type: :json}
|
31
|
+
RestClient.post url, message, {content_type: :json, application_secret: @application_secret}
|
25
32
|
end
|
26
33
|
|
27
34
|
def format(tag, time, record)
|
@@ -29,6 +36,10 @@ module Fluent
|
|
29
36
|
end
|
30
37
|
|
31
38
|
def generate_produce_url
|
39
|
+
unless @produce_url.nil? || @produce_url == ''
|
40
|
+
return @produce_url
|
41
|
+
end
|
42
|
+
|
32
43
|
if @use_https
|
33
44
|
@protocol = 'https'
|
34
45
|
end
|
@@ -36,7 +47,7 @@ module Fluent
|
|
36
47
|
return "#{@protocol}://#{@produce_host}:#{@produce_port}/str/#{@stream_id}/st/#{@store_id}/fw/#{@forwarder_id}/cl/#{@client_id}/produce/#{@produce_topic}"
|
37
48
|
end
|
38
49
|
|
39
|
-
def
|
50
|
+
def configure_params_k8(params)
|
40
51
|
@stream_id = params['baritoStreamId']
|
41
52
|
@produce_host = params['baritoProduceHost']
|
42
53
|
@produce_port = params['baritoProducePort']
|
@@ -53,10 +64,21 @@ module Fluent
|
|
53
64
|
if @use_kubernetes
|
54
65
|
next unless not record['kubernetes']['labels'].nil?
|
55
66
|
params = record['kubernetes']['labels']
|
56
|
-
|
67
|
+
configure_params_k8(params)
|
68
|
+
|
69
|
+
next unless not @stream_id.nil? and @stream_id != ''
|
70
|
+
end
|
71
|
+
|
72
|
+
unless record.has_key?(TIMESTAMP_FIELD)
|
73
|
+
t = Time.now
|
74
|
+
unless time.nil?
|
75
|
+
if time.is_a?(Integer)
|
76
|
+
t = Time.at(time)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
record[TIMESTAMP_FIELD] = t.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
|
57
80
|
end
|
58
81
|
|
59
|
-
next unless not @stream_id.nil? and @stream_id != ''
|
60
82
|
message = record.to_json
|
61
83
|
url = generate_produce_url
|
62
84
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BaritoLog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|