fluent-plugin-lm-logs 1.0.6 → 1.1.0

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: 7b7c2e1fc4c9c42e768327c9dead6b9eaa9f8a77b44ea7697b51306617e2702a
4
- data.tar.gz: 4aee4bdb365b8c7efd52c2aa33ed8d5b0f83cb3ca7e551986062721b33faea24
3
+ metadata.gz: 19349cb3a0b92808dbf10c877ddefd7afae737fd2b643de6fb4c9b44b613dd08
4
+ data.tar.gz: 5cd7858230f353def6da39d4a3669ff236560149deb0a7ea32f344eb8d67430b
5
5
  SHA512:
6
- metadata.gz: f96d200ceb54255e82e09248179b442032c96a1f6bf28efeb410a8a5b4f9423ad5c08815f71cc9a47b2f03c9bbaeef258cdfe52b435b168e65cdaa0bb832adbd
7
- data.tar.gz: 8dbfcce551188386379bb479021e24dc8b027f6edba4fd0f87ef17ef4eda1535010a0eaf5ca973fda304cfed339a4b0e53306e9fda012336686cc70c75d5b868
6
+ metadata.gz: 40af1f578e4307a26dce585dd5817f131fcc938cb8a16561441069960950e90a6f5db7abb5af79e091be39ed9f8eab273df33fcc64fc37a71d8d5830e2eabf79
7
+ data.tar.gz: b14b17c709c137a1b35b7043faa32bde3ede821036d22732de429757e5c70f187b82094069adeefd60a974923d4b1623ea4b0a6b6ce3e6a46b1e1e9d7f0cba4c
@@ -25,9 +25,9 @@ module Fluent
25
25
 
26
26
  # config_param defines a parameter. You can refer a parameter via @path instance variable
27
27
 
28
- config_param :access_id, :string, :default => "access_id"
28
+ config_param :access_id, :string, :default => nil
29
29
 
30
- config_param :access_key, :string, :default => "access_key"
30
+ config_param :access_key, :string, :default => nil, secret: true
31
31
 
32
32
  config_param :company_name, :string, :default => "company_name"
33
33
 
@@ -49,6 +49,9 @@ module Fluent
49
49
 
50
50
  config_param :http_proxy, :string, :default => nil
51
51
 
52
+ # Use bearer token for auth.
53
+ config_param :bearer_token, :string, :default => nil, secret: true
54
+
52
55
  # This method is called before starting.
53
56
  # 'conf' is a Hash that includes configuration parameters.
54
57
  # If the configuration is invalid, raise Fluent::ConfigError.
@@ -60,6 +63,7 @@ module Fluent
60
63
  # Open sockets or files here.
61
64
  def start
62
65
  super
66
+ configure_auth
63
67
  proxy_uri = :ENV
64
68
  if @http_proxy
65
69
  proxy_uri = URI.parse(http_proxy)
@@ -73,6 +77,17 @@ module Fluent
73
77
  @uri = URI.parse(@url)
74
78
  end
75
79
 
80
+ def configure_auth
81
+ @use_bearer_instead_of_lmv1 = false
82
+ if @access_id == nil || @access_key == nil
83
+ log.info "Access Id or access key null. Using bearer token for authentication."
84
+ @use_bearer_instead_of_lmv1 = true
85
+ end
86
+ if @use_bearer_instead_of_lmv1 && @bearer_token == nil
87
+ log.error "Bearer token not specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor."
88
+ raise ArgumentError, 'No valid authentication specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor.'
89
+ end
90
+ end
76
91
  # This method is called when shutting down.
77
92
  # Shutdown the thread and close sockets or files here.
78
93
  def shutdown
@@ -210,15 +225,20 @@ module Fluent
210
225
 
211
226
 
212
227
  def generate_token(events)
213
- timestamp = DateTime.now.strftime('%Q')
214
- signature = Base64.strict_encode64(
215
- OpenSSL::HMAC.hexdigest(
216
- OpenSSL::Digest.new('sha256'),
217
- @access_key,
218
- "POST#{timestamp}#{events.to_json}/log/ingest"
219
- )
220
- )
221
- "LMv1 #{@access_id}:#{signature}:#{timestamp}"
228
+
229
+ if @use_bearer_instead_of_lmv1
230
+ return "Bearer #{@bearer_token}"
231
+ else
232
+ timestamp = DateTime.now.strftime('%Q')
233
+ signature = Base64.strict_encode64(
234
+ OpenSSL::HMAC.hexdigest(
235
+ OpenSSL::Digest.new('sha256'),
236
+ @access_key,
237
+ "POST#{timestamp}#{events.to_json}/log/ingest"
238
+ )
239
+ )
240
+ return "LMv1 #{@access_id}:#{signature}:#{timestamp}"
241
+ end
222
242
  end
223
243
  end
224
244
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LmLogsFluentPlugin
4
- VERSION = '1.0.6'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-lm-logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LogicMonitor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-21 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd