Skip to content

Commit f0df018

Browse files
jimmyjones2untergeek
authored andcommitted
Add host to @metadata like path, in case event also contains field of same name
Fixes #136
1 parent dfbe5c2 commit f0df018

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 3.1.1
2+
- Add host to @metadata
13
## 3.1.0
24
- Use native `--path.data` for Logstash 5.0 for sincedb files.
35
## 3.0.3

lib/logstash/inputs/file.rb

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ def run(queue)
314314
end # def run
315315

316316
def post_process_this(event)
317+
event.set("[@metadata][host]", @host)
317318
event.set("host", @host) if !event.include?("host")
318319
decorate(event)
319320
@queue << event

logstash-input-file.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-file'
4-
s.version = '3.1.0'
4+
s.version = '3.1.1'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Stream events from files."
77
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"

spec/inputs/file_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@
122122

123123
insist { events[0].get("path") } == "my_path"
124124
insist { events[0].get("host") } == "my_host"
125+
insist { events[0].get("[@metadata][host]") } == "#{Socket.gethostname.force_encoding(Encoding::UTF_8)}"
125126

126127
insist { events[1].get("path") } == "#{tmpfile_path}"
127128
insist { events[1].get("host") } == "#{Socket.gethostname.force_encoding(Encoding::UTF_8)}"
129+
insist { events[1].get("[@metadata][host]") } == "#{Socket.gethostname.force_encoding(Encoding::UTF_8)}"
128130
end
129131

130132
context "when sincedb_path is an existing directory" do

0 commit comments

Comments
 (0)