Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jian Chen committed Feb 24, 2020
1 parent c94da68 commit 201d047
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ output {
channel_identifier => "FE0ECFAD-13D5-401B-847D-77833BD77133"
is_raw => true
is_batch => true
mapping => {
"event" => "%{message}"
}
}
}
</code></pre>
Expand Down Expand Up @@ -93,4 +90,4 @@ bin/logstash-plugin install --no-verify
bin/plugin install --no-verify

```
- Start Logstash and proceed to test the plugin
- Start Logstash and proceed to test the plugin
11 changes: 3 additions & 8 deletions lib/logstash/outputs/splunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,7 @@ def log_failure(message, opts)
def event_body(event)
# TODO: Create an HTTP post data codec, use that here
if @is_batch
if @is_raw
event.map {|e| map_event(e).fetch("message") }.join("\n")
else
event.map {|e| LogStash::Json.dump(map_event(e)) }.join("\n")
end
event.map {|e| LogStash::Json.dump(map_event(e)) }.join("\n")
else
LogStash::Json.dump(map_event(event))
end
Expand Down Expand Up @@ -330,11 +326,10 @@ def convert_mapping(mapping, event)

def map_event(event)
if @mapping
msg_body = convert_mapping(@mapping, event)
convert_mapping(@mapping, event)
else
msg_body = event.to_hash
event.to_hash
end
{"event" => msg_body}
end

def event_headers(event)
Expand Down

0 comments on commit 201d047

Please sign in to comment.