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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4bff9939e612862fcba679e5b72f93826fe3160
4
- data.tar.gz: e87db4f05d56c5063ddbb688a7999c72035667b8
3
+ metadata.gz: 54e95e18ae1e0e0b7d671f769d1dfb007faad8e9
4
+ data.tar.gz: 89b169bb424effbf3083bd9bdf498c7a7471df9d
5
5
  SHA512:
6
- metadata.gz: 439698abc1aa840d0ae1de93ca7628f1a28d4e9ca92a4310d5d7e4f7bb7c6454837e9e9552a45617bb46978b50a2e785121b2fc7162cf5d717dca829c77afe7e
7
- data.tar.gz: 96095d1dc84a346ce1b6ea7fa2f5673b9c04d8c4362cd1a72562aeb76dd8e7b770a2a29fe657d536c6213ad04b0c880ecc08696573a71c7543bf5a0bafcafe23
6
+ metadata.gz: 7f598318664a9b9d02403e29212a6e55626e17ba8688573872a2e5773f528b32ce6982eb1194746d89eeaee81e92d5e343bc2308f446fcc54c251fe12aad8749
7
+ data.tar.gz: '0052769ee449f19df1369bb89a17c5064a17d409b2a67a7fae76b54b054117460235397b084d795514469fe2485e8e732ad4c12a461e1ee124d4430c8f5de7e7'
@@ -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.1"
6
+ spec.version = "0.1.2"
7
7
  spec.authors = ["BaritoLog"]
8
8
  spec.email = [""]
9
9
 
@@ -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 configure_params(params)
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
- configure_params(params)
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.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-05 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler