logstash-output-lmlogs 2.0.0 → 2.0.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
  SHA256:
3
- metadata.gz: 46b4784b47b720c638e2f6cb53ace887c3ff3bd821cc27ca675fc3bf6b5b3325
4
- data.tar.gz: 2dd4c277e4b769d4580ea1474d00f058d2f08f1d718da6e715c51ab16f722679
3
+ metadata.gz: a4846f9bbbd52ab6c5f801aa3d6938e7fc58311408588ab3e57adeb12c852b02
4
+ data.tar.gz: 23239bd62adc2baf7d8340bcfccf5b63b85bf5b30c189420465f66d3b6584d51
5
5
  SHA512:
6
- metadata.gz: 118161034fbd6b10b946449a75ccabc6fcce733006824711bdbcde2fff864f65ac249bd1de2f78600e975e71f47740881e946c4f2335a82956e6a8b130f44af5
7
- data.tar.gz: f28a74d295e3f14bca4bfed4389c5dd32cfaaecb8f5b550168f2542494b0876c50b95d42661d101879284f9a7f532a74551b7fa1989abf83289b046f210e33de
6
+ metadata.gz: d24e42560a21de68485a601ac2f82e60559269801597756848c4d8d000eace113bc07265e2352f967224f2c43f2abf3f98c47da2855bec8123745429c4e249d8
7
+ data.tar.gz: b72a1fb18c3bb21d31c6d78d4291b293c272cea084f761f2359edd9d984b3c01a467bef42c76a7dd3821b590fabebbc2cd3b5a260ba94f3377b6b041a9ca1af0
data/CHANGELOG.md CHANGED
@@ -16,3 +16,5 @@
16
16
  - Fix user agent populated in headers
17
17
  ## 2.0.0
18
18
  - Dont send event metadata by default. Add config include_metadata_keys for including custom metadata
19
+ ## 2.0.1
20
+ - Fix incomplete json metadata error.
data/README.md CHANGED
@@ -15,12 +15,14 @@ Run the following on your Logstash instance
15
15
  output {
16
16
  lmlogs {
17
17
  portal_name => "your company name"
18
+ portal_domain => "your LM company domain."
18
19
  access_id => "your lm access id"
19
20
  access_key => "your access key"
20
21
  }
21
22
  }
22
23
  ```
23
- You would need either `access_id` and `access_id` both or `bearer_token` for authentication with Logicmonitor.
24
+ You would need either `access_id` and `access_id` both or `bearer_token` for authentication with Logicmonitor.
25
+ The portal_domain is the domain of your LM portal. If not set the default is set to `logicmonitor.com`. Eg if your LM portal URL is `https://test.domain.com`, portal_name should be set to `test` and portal_domain to `domain.com`
24
26
 
25
27
 
26
28
 
@@ -91,9 +91,13 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
91
91
  # LM Portal Name
92
92
  config :portal_name, :validate => :string, :required => true
93
93
 
94
+ # LM Portal Domain. Default will be logicmonitor.com
95
+ config :portal_domain, :validate => :string, :required => false, :default => "logicmonitor.com"
96
+
94
97
  # Username to use for HTTP auth.
95
98
  config :access_id, :validate => :string, :required => false, :default => nil
96
99
 
100
+
97
101
  # Include/Exclude metadata from sending to LM Logs
98
102
  config :include_metadata, :validate => :boolean, :default => false
99
103
 
@@ -121,6 +125,11 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
121
125
  :size => @@MAX_PAYLOAD_SIZE)
122
126
  configure_auth
123
127
 
128
+ # Check if `portal_domain` is an empty string and set the default value
129
+ if @portal_domain.nil? || @portal_domain.strip.empty?
130
+ @portal_domain = "logicmonitor.com"
131
+ end
132
+
124
133
  @final_metadata_keys = Hash.new
125
134
  if @include_metadata_keys.any?
126
135
  include_metadata_keys.each do | nested_key |
@@ -201,7 +210,7 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
201
210
  def send_batch(events)
202
211
  log_debug("Started sending logs to LM: ",
203
212
  :time => Time::now.utc)
204
- url = "https://" + @portal_name + ".logicmonitor.com/rest/log/ingest"
213
+ url = "https://" + @portal_name + "." + @portal_domain +"/rest/log/ingest"
205
214
  body = events.to_json
206
215
  auth_string = generate_auth_string(body)
207
216
  request = client.post(url, {
@@ -298,7 +307,12 @@ class LogStash::Outputs::LMLogs < LogStash::Outputs::Base
298
307
  elsif @final_metadata_keys
299
308
  @final_metadata_keys.each do | key, value |
300
309
  nestedVal = event_json
301
- value.each { |x| nestedVal = nestedVal[x] }
310
+ value.each do |x|
311
+ if nestedVal == nil
312
+ break
313
+ end
314
+ nestedVal = nestedVal[x]
315
+ end
302
316
  if nestedVal != nil
303
317
  lmlogs_event[key] = nestedVal
304
318
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LmLogsLogstashPlugin
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.2'
5
5
  end
@@ -83,4 +83,26 @@ describe LogStash::Outputs::LMLogs do
83
83
  puts " hash diff : #{Hashdiff.diff(constructed_event,expected_event)}"
84
84
  expect(Hashdiff.diff(constructed_event,expected_event)).to eq([])
85
85
  end
86
+
87
+ it "Netsted key that doesn not exist should not break" do
88
+ plugin = create_output_plugin_with_conf({
89
+ "portal_name" => "localhost",
90
+ "access_id" => "abcd",
91
+ "access_key" => "abcd",
92
+ "lm_property" => "system.hostname",
93
+ "property_key" => "host",
94
+ "include_metadata_keys" => %w[nested1.nested2.nestedkey_that_doesnt_exist]
95
+ })
96
+ constructed_event = plugin.processEvent(logstash_event)
97
+ expected_event = {
98
+ "message" => "hello this is log 1",
99
+ "timestamp" => logstash_event.timestamp,
100
+ "_lm.resourceId" => {"system.hostname" => "host1"}
101
+ }
102
+ puts " actual : #{constructed_event} \n expected : #{expected_event}"
103
+ puts " hash diff : #{Hashdiff.diff(constructed_event,expected_event)}"
104
+ expect(Hashdiff.diff(constructed_event,expected_event)).to eq([])
105
+ end
106
+
107
+
86
108
  end
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: 2.0.0
4
+ version: 2.0.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-11-24 00:00:00.000000000 Z
11
+ date: 2024-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement