logstash-output-lmlogs 1.0.1 → 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: d6d83c13647807e66508b976a76aa5481dc4412c8631d0184f2a4cd793384a3e
4
- data.tar.gz: b2d5a69f85702525e83095cc9cab180ab194402873fe18317e597cf2f591331d
3
+ metadata.gz: d0215e007f329ca2c6538f6ec2d65932fe43d87c1396772e03c98ca132bc932e
4
+ data.tar.gz: 288bf0b9b00ab06c19a02d4f540daed77d50a797fcaaa4c96912b2ca1cc59140
5
5
  SHA512:
6
- metadata.gz: e7f30119cf9877d14b7362eb3c0fe6dbec7ed8fb95de34596ff1311ced6fc511286f982680ad3d50c632640fc4d7ec2e53d54548fd3081155872d63eb1d25936
7
- data.tar.gz: 693702b1e37126660b117de0b34a8758579bf6fa20e26479b55b7e2022090d64497041c7ddb9563d169297f41aa82ce142d6b7e13a97558defdc0d9e8f3300c4
6
+ metadata.gz: 7703c1da2e96bb1fbf1f55e72c04f8d3c22c0fe164f07496d70535b7eb358f67064b0021c3857b551e46419a6a1a62f5a26a88efed83c4b3135be1a48da943be
7
+ data.tar.gz: a49bbfa5e88c5dc18d72d7d37f5141da160ee020802a2812680b5433c343cab5a70d11a5af94f2ecde638455efc836d8b47aca798411dba648b369322b8cb25d
@@ -98,12 +98,17 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
98
98
 
99
99
  @@MAX_PAYLOAD_SIZE = 8*1024*1024
100
100
 
101
+ # For developer debugging.
102
+ @@CONSOLE_LOGS = false
103
+
101
104
  public
102
105
  def register
103
106
  @total = 0
104
107
  @total_failed = 0
105
108
  logger.info("Initialized LogicMonitor output plugin with configuration",
106
109
  :host => @host)
110
+ logger.info("Max Payload Size: ",
111
+ :size => @@MAX_PAYLOAD_SIZE)
107
112
 
108
113
  end # def register
109
114
 
@@ -141,7 +146,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
141
146
  # :eager => true
142
147
  # }
143
148
  end
144
- @logger.debug("manticore client config ", :client => c)
149
+ log_debug("manticore client config: ", :client => c)
145
150
  return c
146
151
  end
147
152
 
@@ -174,6 +179,8 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
174
179
  end
175
180
 
176
181
  def send_batch(events)
182
+ log_debug("Started sending logs to LM: ",
183
+ :time => Time::now.utc)
177
184
  url = "https://" + @portal_name + ".logicmonitor.com/rest/log/ingest"
178
185
  body = events.to_json
179
186
  auth_string = generate_auth_string(body)
@@ -189,7 +196,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
189
196
  request.on_success do |response|
190
197
  if response.code == 202
191
198
  @total += events.length
192
- @logger.debug("Successfully sent ",
199
+ log_debug("Successfully sent ",
193
200
  :response_code => response.code,
194
201
  :batch_size => events.length,
195
202
  :total_sent => @total,
@@ -214,10 +221,9 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
214
221
 
215
222
  request.on_failure do |exception|
216
223
  @total_failed += 1
217
- log_failure("Could not access URL",
224
+ log_failure("The request failed. ",
218
225
  :url => url,
219
226
  :method => @http_method,
220
- :body => body,
221
227
  :message => exception.message,
222
228
  :class => exception.class.name,
223
229
  :backtrace => exception.backtrace,
@@ -225,7 +231,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
225
231
  )
226
232
  end
227
233
 
228
- @logger.debug("Sending LM Logs",
234
+ log_debug("Completed sending logs to LM",
229
235
  :total => @total,
230
236
  :time => Time::now.utc)
231
237
  request.call
@@ -234,20 +240,29 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
234
240
  @logger.error("[Exception=] #{e.message} #{e.backtrace}")
235
241
  end
236
242
 
243
+ def log_debug(message, *opts)
244
+ if @@CONSOLE_LOGS
245
+ puts "[#{DateTime::now}] [logstash.outputs.lmlogs] [DEBUG] #{message} #{opts.to_s}"
246
+ elsif debug
247
+ @logger.debug(message, *opts)
248
+ end
249
+ end
237
250
 
238
251
  public
239
252
  def multi_receive(events)
240
- puts @@MAX_PAYLOAD_SIZE
241
- if debug
242
- puts events.to_json
243
- end
253
+ if events.length() > 0
254
+ log_debug(events.to_json)
255
+ end
244
256
 
245
257
  events.each_slice(@batch_size) do |chunk|
246
258
  documents = []
247
259
  chunk.each do |event|
248
- lmlogs_event = {
249
- message: event.get(@message_key).to_s
250
- }
260
+ event_json = JSON.parse(event.to_json)
261
+ lmlogs_event = event_json
262
+ lmlogs_event.delete("@timestamp") # remove redundant timestamp field
263
+ lmlogs_event["event"].delete("original") # remove redundant log field
264
+
265
+ lmlogs_event["message"] = event.get(@message_key).to_s
251
266
 
252
267
  lmlogs_event["_lm.resourceId"] = {}
253
268
  lmlogs_event["_lm.resourceId"]["#{@lm_property}"] = event.get(@property_key.to_s)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-lmlogs'
3
- s.version = '1.0.1'
4
- s.licenses = ['Apache License (2.0)']
3
+ s.version = '1.1.0'
4
+ s.licenses = ['Apache-2.0']
5
5
  s.summary = "Logstash output plugin for LM Logs"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
7
7
  s.authors = ["LogicMonitor"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
16
 
17
17
  # Special flag to let us know this is actually a logstash plugin
18
- s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" , "rubygems_mfa_required" => "false"}
19
19
 
20
20
  # Gem dependencies
21
21
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-lmlogs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
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: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -94,10 +94,11 @@ files:
94
94
  - spec/outputs/lmlogs_spec.rb
95
95
  homepage: https://www.logicmonitor.com
96
96
  licenses:
97
- - Apache License (2.0)
97
+ - Apache-2.0
98
98
  metadata:
99
99
  logstash_plugin: 'true'
100
100
  logstash_group: output
101
+ rubygems_mfa_required: 'false'
101
102
  post_install_message:
102
103
  rdoc_options: []
103
104
  require_paths:
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubygems_version: 3.2.29
117
+ rubygems_version: 3.3.25
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Logstash output plugin for LM Logs