fluent-plugin-lm-logs 1.1.0 → 1.2.2

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: 19349cb3a0b92808dbf10c877ddefd7afae737fd2b643de6fb4c9b44b613dd08
4
- data.tar.gz: 5cd7858230f353def6da39d4a3669ff236560149deb0a7ea32f344eb8d67430b
3
+ metadata.gz: e2f2d379ca3023506ac1e1781ae37e44bdd57558894d7f9ee743c6d9d823894c
4
+ data.tar.gz: 8a88cc0984177c019f1b357ab2d72a8d8d956cb73683b48bb0e4bf0e71f4c56f
5
5
  SHA512:
6
- metadata.gz: 40af1f578e4307a26dce585dd5817f131fcc938cb8a16561441069960950e90a6f5db7abb5af79e091be39ed9f8eab273df33fcc64fc37a71d8d5830e2eabf79
7
- data.tar.gz: b14b17c709c137a1b35b7043faa32bde3ede821036d22732de429757e5c70f187b82094069adeefd60a974923d4b1623ea4b0a6b6ce3e6a46b1e1e9d7f0cba4c
6
+ metadata.gz: 5b72a7ca3c7cfdc2179244cdd82ee7f830f63c98a145b61bb5e5140d8d00dfa6ec0307d422546e5e33fc94106e32aaaa624936a02df83aef4d33b063292fba07
7
+ data.tar.gz: 2a9928406e7c5bfb460e15ef22df5b1d3f711aca6bcc171e95aa3ba663b59bae123cdd5e3a168b5a9887b4d8bb798e6188ec08181601f8a07424461a5b86e7b0
data/README.md CHANGED
@@ -66,6 +66,7 @@ See the [LogicMonitor Helm repository](https://github.com/logicmonitor/k8s-helm-
66
66
  | `resource_mapping` | The mapping that defines the source of the log event to the LM resource. In this case, the `<event_key>` in the incoming event is mapped to the value of `<lm_property>`.|
67
67
  | `access_id` | LM API Token access ID. |
68
68
  | `access_key` | LM API Token access key. |
69
+ | `bearer_token` | LM API Bearer Token. Either specify `access_id` and `access_key` both or `bearer_token`. If all specified, LMv1 token(`access_id` and `access_key`) will be used for authentication with Logicmonitor. |
69
70
  | `flush_interval` | Defines the time in seconds to wait before sending batches of logs to LogicMonitor. Default is `60s`. |
70
71
  | `debug` | When `true`, logs more information to the fluentd console. |
71
72
  | `force_encoding` | Specify charset when logs contains invalid utf-8 characters. |
data/Rakefile CHANGED
@@ -3,5 +3,6 @@ require "rake/testtask"
3
3
  task default: "test"
4
4
 
5
5
  Rake::TestTask.new do |task|
6
- task.pattern = "test/plugin/*.rb"
7
- end
6
+ task.libs << "test"
7
+ task.test_files = Dir.glob('test/plugin/*.rb') - ['test/plugin/test_performance.rb']
8
+ end
@@ -36,7 +36,7 @@ module Fluent
36
36
  config_param :debug, :bool, :default => false
37
37
 
38
38
  config_param :include_metadata, :bool, :default => false
39
-
39
+
40
40
  config_param :force_encoding, :string, :default => ""
41
41
 
42
42
  config_param :compression, :string, :default => ""
@@ -48,7 +48,7 @@ module Fluent
48
48
  config_param :device_less_logs, :bool, :default => false
49
49
 
50
50
  config_param :http_proxy, :string, :default => nil
51
-
51
+
52
52
  # Use bearer token for auth.
53
53
  config_param :bearer_token, :string, :default => nil, secret: true
54
54
 
@@ -59,6 +59,10 @@ module Fluent
59
59
  super
60
60
  end
61
61
 
62
+ def multi_workers_ready?
63
+ true
64
+ end
65
+
62
66
  # This method is called when starting.
63
67
  # Open sockets or files here.
64
68
  def start
@@ -79,11 +83,11 @@ module Fluent
79
83
 
80
84
  def configure_auth
81
85
  @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."
86
+ if is_blank(@access_id) || is_blank(@access_key)
87
+ log.info "Access Id or access key blank / null. Using bearer token for authentication."
84
88
  @use_bearer_instead_of_lmv1 = true
85
- end
86
- if @use_bearer_instead_of_lmv1 && @bearer_token == nil
89
+ end
90
+ if @use_bearer_instead_of_lmv1 && is_blank(@bearer_token)
87
91
  log.error "Bearer token not specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor."
88
92
  raise ArgumentError, 'No valid authentication specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor.'
89
93
  end
@@ -150,7 +154,7 @@ module Fluent
150
154
  else
151
155
  lm_event[DEVICELESS_KEY_SERVICE] = encode_if_necessary(record[DEVICELESS_KEY_SERVICE])
152
156
  if record[DEVICELESS_KEY_NAMESPACE]!=nil
153
- lm_event[DEVICELESS_KEY_NAMESPACE] = encode_if_necessary(record[DEVICELESS_KEY_NAMESPACE])
157
+ lm_event[DEVICELESS_KEY_NAMESPACE] = encode_if_necessary(record[DEVICELESS_KEY_NAMESPACE])
154
158
  end
155
159
  end
156
160
  end
@@ -167,13 +171,13 @@ module Fluent
167
171
  end
168
172
 
169
173
  def get_metadata(record)
170
- #if encoding is not defined we will skip going through each key val
174
+ #if encoding is not defined we will skip going through each key val
171
175
  #and return the whole record for performance reasons in case of a bulky record.
172
- if @force_encoding == ""
176
+ if @force_encoding == ""
173
177
  return record
174
178
  else
175
179
  lm_event = {}
176
- record.each do |key, value|
180
+ record.each do |key, value|
177
181
  lm_event["#{key}"] = get_encoded_string(value)
178
182
  end
179
183
  return lm_event
@@ -194,7 +198,7 @@ module Fluent
194
198
 
195
199
  def send_batch(events)
196
200
  body = events.to_json
197
-
201
+
198
202
  if @debug
199
203
  log.info "Sending #{events.length} events to logic monitor at #{@url}"
200
204
  log.info "Request json #{body}"
@@ -218,7 +222,7 @@ module Fluent
218
222
  end
219
223
 
220
224
  resp = @http_client.request @uri, request
221
- if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
225
+ if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
222
226
  log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']} message:#{resp.body}"
223
227
  end
224
228
  end
@@ -228,7 +232,7 @@ module Fluent
228
232
 
229
233
  if @use_bearer_instead_of_lmv1
230
234
  return "Bearer #{@bearer_token}"
231
- else
235
+ else
232
236
  timestamp = DateTime.now.strftime('%Q')
233
237
  signature = Base64.strict_encode64(
234
238
  OpenSSL::HMAC.hexdigest(
@@ -238,7 +242,16 @@ module Fluent
238
242
  )
239
243
  )
240
244
  return "LMv1 #{@access_id}:#{signature}:#{timestamp}"
241
- end
245
+ end
246
+ end
247
+
248
+ def is_blank(str)
249
+ if str.nil? || str.to_s.strip.empty?
250
+ return true
251
+ else
252
+ return false
253
+ end
242
254
  end
255
+
243
256
  end
244
- end
257
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LmLogsFluentPlugin
4
- VERSION = '1.1.0'
5
- end
4
+ VERSION = '1.2.2'
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.1.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LogicMonitor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.4.10
83
+ rubygems_version: 3.5.3
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: LogicMonitor logs fluentd output plugin