Skip to content

Commit 73ec683

Browse files
Merge pull request #8 from logicmonitor/DEV-118714-implement-functionality-to-exclude-metadata-from-lm-logs-logstash-plugin
Dev 118714 implement functionality to exclude metadata from lm logs logstash plugin
2 parents 2ee5edf + d118b18 commit 73ec683

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ output {
3333
| keep_timestamp | If false, LM Logs will use the ingestion timestamp as the event timestamp | true |
3434
| timestamp_is_key | If true, LM Logs will use a specified key as the event timestamp | false |
3535
| 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 |
3637

3738
See the [source code](lib/logstash/outputs/lmlogs.rb) for the full list of options
3839

lib/logstash/outputs/lmlogs.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class InvalidHTTPConfigError < StandardError; end
9393
# Username to use for HTTP auth.
9494
config :access_id, :validate => :string, :required => true
9595

96+
# Include/Exclude metadata from sending to LM Logs
97+
config :include_metadata, :validate => :boolean, :default => true
98+
9699
# Password to use for HTTP auth
97100
config :access_key, :validate => :password, :required => true
98101

@@ -258,12 +261,15 @@ def multi_receive(events)
258261
documents = []
259262
chunk.each do |event|
260263
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+
lmlogs_event = {}
264265

265-
lmlogs_event["message"] = event.get(@message_key).to_s
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
266271

272+
lmlogs_event["message"] = event.get(@message_key).to_s
267273
lmlogs_event["_lm.resourceId"] = {}
268274
lmlogs_event["_lm.resourceId"]["#{@lm_property}"] = event.get(@property_key.to_s)
269275

logstash-output-lmlogs.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-lmlogs'
3-
s.version = '1.1.0'
3+
s.version = '1.2.0'
44
s.licenses = ['Apache-2.0']
55
s.summary = "Logstash output plugin for LM Logs"
66
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"

0 commit comments

Comments
 (0)