logstash-output-lmlogs 1.0.1 → 1.2.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: 6420014cba38216a8de9dea6094e645b80e56a0751a954db2ce76fc6e57e5b72
4
+ data.tar.gz: 06113b6ebb5cc2ca01017a7a801c48ac990e57c15dad4d6ad45aef811c8bf962
5
5
  SHA512:
6
- metadata.gz: e7f30119cf9877d14b7362eb3c0fe6dbec7ed8fb95de34596ff1311ced6fc511286f982680ad3d50c632640fc4d7ec2e53d54548fd3081155872d63eb1d25936
7
- data.tar.gz: 693702b1e37126660b117de0b34a8758579bf6fa20e26479b55b7e2022090d64497041c7ddb9563d169297f41aa82ce142d6b7e13a97558defdc0d9e8f3300c4
6
+ metadata.gz: 4b2ed08cbd38d9fa41b715372384fde2872e9a98552352b4494b13185e62c5fd1df1de26a13a7b4c81951ae8c91d6fb2cad1677c152e17c260a73ca1fbd5ef2c
7
+ data.tar.gz: d42834b440dd45429b4cd0705487c6ed23c68176b560b3af1b74d315bff204ac4608080e452e7404437a636578f58a0b4984bf5124e0e1758d2368aca0456ab9
data/README.md CHANGED
@@ -33,6 +33,7 @@ output {
33
33
  | keep_timestamp | If false, LM Logs will use the ingestion timestamp as the event timestamp | true |
34
34
  | timestamp_is_key | If true, LM Logs will use a specified key as the event timestamp | false |
35
35
  | timestamp_key | If timestamp_is_key is set, LM Logs will use this key in the event as the timestamp | "logtimestamp" |
36
+ | include_metadata | If false, the metadata fields will not be sent to LM Logs | true |
36
37
 
37
38
  See the [source code](lib/logstash/outputs/lmlogs.rb) for the full list of options
38
39
 
@@ -93,17 +93,25 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
93
93
  # Username to use for HTTP auth.
94
94
  config :access_id, :validate => :string, :required => true
95
95
 
96
+ # Include/Exclude metadata from sending to LM Logs
97
+ config :include_metadata, :validate => :boolean, :default => true
98
+
96
99
  # Password to use for HTTP auth
97
100
  config :access_key, :validate => :password, :required => true
98
101
 
99
102
  @@MAX_PAYLOAD_SIZE = 8*1024*1024
100
103
 
104
+ # For developer debugging.
105
+ @@CONSOLE_LOGS = false
106
+
101
107
  public
102
108
  def register
103
109
  @total = 0
104
110
  @total_failed = 0
105
111
  logger.info("Initialized LogicMonitor output plugin with configuration",
106
112
  :host => @host)
113
+ logger.info("Max Payload Size: ",
114
+ :size => @@MAX_PAYLOAD_SIZE)
107
115
 
108
116
  end # def register
109
117
 
@@ -141,7 +149,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
141
149
  # :eager => true
142
150
  # }
143
151
  end
144
- @logger.debug("manticore client config ", :client => c)
152
+ log_debug("manticore client config: ", :client => c)
145
153
  return c
146
154
  end
147
155
 
@@ -174,6 +182,8 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
174
182
  end
175
183
 
176
184
  def send_batch(events)
185
+ log_debug("Started sending logs to LM: ",
186
+ :time => Time::now.utc)
177
187
  url = "https://" + @portal_name + ".logicmonitor.com/rest/log/ingest"
178
188
  body = events.to_json
179
189
  auth_string = generate_auth_string(body)
@@ -189,7 +199,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
189
199
  request.on_success do |response|
190
200
  if response.code == 202
191
201
  @total += events.length
192
- @logger.debug("Successfully sent ",
202
+ log_debug("Successfully sent ",
193
203
  :response_code => response.code,
194
204
  :batch_size => events.length,
195
205
  :total_sent => @total,
@@ -214,10 +224,9 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
214
224
 
215
225
  request.on_failure do |exception|
216
226
  @total_failed += 1
217
- log_failure("Could not access URL",
227
+ log_failure("The request failed. ",
218
228
  :url => url,
219
229
  :method => @http_method,
220
- :body => body,
221
230
  :message => exception.message,
222
231
  :class => exception.class.name,
223
232
  :backtrace => exception.backtrace,
@@ -225,7 +234,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
225
234
  )
226
235
  end
227
236
 
228
- @logger.debug("Sending LM Logs",
237
+ log_debug("Completed sending logs to LM",
229
238
  :total => @total,
230
239
  :time => Time::now.utc)
231
240
  request.call
@@ -234,21 +243,33 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
234
243
  @logger.error("[Exception=] #{e.message} #{e.backtrace}")
235
244
  end
236
245
 
246
+ def log_debug(message, *opts)
247
+ if @@CONSOLE_LOGS
248
+ puts "[#{DateTime::now}] [logstash.outputs.lmlogs] [DEBUG] #{message} #{opts.to_s}"
249
+ elsif debug
250
+ @logger.debug(message, *opts)
251
+ end
252
+ end
237
253
 
238
254
  public
239
255
  def multi_receive(events)
240
- puts @@MAX_PAYLOAD_SIZE
241
- if debug
242
- puts events.to_json
243
- end
256
+ if events.length() > 0
257
+ log_debug(events.to_json)
258
+ end
244
259
 
245
260
  events.each_slice(@batch_size) do |chunk|
246
261
  documents = []
247
262
  chunk.each do |event|
248
- lmlogs_event = {
249
- message: event.get(@message_key).to_s
250
- }
263
+ event_json = JSON.parse(event.to_json)
264
+ lmlogs_event = {}
265
+
266
+ if @include_metadata
267
+ lmlogs_event = event_json
268
+ lmlogs_event.delete("@timestamp") # remove redundant timestamp field
269
+ lmlogs_event["event"].delete("original") # remove redundant log field
270
+ end
251
271
 
272
+ lmlogs_event["message"] = event.get(@message_key).to_s
252
273
  lmlogs_event["_lm.resourceId"] = {}
253
274
  lmlogs_event["_lm.resourceId"]["#{@lm_property}"] = event.get(@property_key.to_s)
254
275
 
@@ -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.2.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.2.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-12-21 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