logstash-input-file 3.0.3 → 3.1.1

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
  SHA1:
3
- metadata.gz: c1a1da31999fd39eae3af8288cd69e1b5ec8e298
4
- data.tar.gz: b30ffb01fc3683e589c45439cf554e8098c4837b
3
+ metadata.gz: 16127b68cf7693ca7dc65af0aa126132e81737f7
4
+ data.tar.gz: 666f96258b9f7aa55396faa30b9da87a854de1a1
5
5
  SHA512:
6
- metadata.gz: 3e183f58570e3396f7b47bd617e14f897d578898e318b92193116180f29d9e64b8bd0c0310512933e8f60a30c3f6911100778b07fff2fbcc663bfd978e92650e
7
- data.tar.gz: 4e395a687436bbc34eee41e5443c702156dab002345bb9bf62a389e60cbd92298ebacd183748b53912c4f86e447f4b0b30bdc24b9487126b8e883d222f03d99b
6
+ metadata.gz: 33b14b46466bf49bf5c1b93e2a4aa1fc641f222e1028306fbc05dc50ebf81d6f923383cc354991e13e009f8ef811995c983ccfec8ed9d52a60e2df09d5ae9736
7
+ data.tar.gz: 970228356e309ad40e870edaa05942a4c71d0128dda511120a284ea4b2e824bc61168939e434dd06eb94e69ba861009ff4e07ec58ff88b52f1ebed695bbdf621
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
+ ## 3.1.1
2
+ - Add host to @metadata
3
+ ## 3.1.0
4
+ - Use native `--path.data` for Logstash 5.0 for sincedb files.
1
5
  ## 3.0.3
2
6
  - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
3
-
4
7
  ## 3.0.2
5
8
  - relax constrains of `logstash-devutils` see https://github.com/elastic/logstash-devutils/issues/48
6
9
  ## 3.0.1
data/CONTRIBUTORS CHANGED
@@ -18,6 +18,7 @@ Contributors:
18
18
  * elliot moore (em295)
19
19
  * yjpa7145
20
20
  * Guy Boertje (guyboertje)
21
+ * Aaron Mildenstein (untergeek)
21
22
 
22
23
  Note: If you've sent us patches, bug reports, or otherwise contributed to
23
24
  Logstash, and you aren't on the list above and want to be, please let us know
@@ -5,14 +5,18 @@ require "logstash/codecs/identity_map_codec"
5
5
 
6
6
  require "pathname"
7
7
  require "socket" # for Socket.gethostname
8
+ require "fileutils"
8
9
 
9
10
  # Stream events from files, normally by tailing them in a manner
10
11
  # similar to `tail -0F` but optionally reading them from the
11
12
  # beginning.
12
13
  #
13
- # By default, each event is assumed to be one line. If you would like
14
- # to join multiple log lines into one event, you'll want to use the
15
- # multiline codec or filter.
14
+ # By default, each event is assumed to be one line and a line is
15
+ # taken to be the text before a newline character.
16
+ # Normally, logging will add a newline to the end of each line written.
17
+
18
+ # If you would like to join multiple log lines into one event,
19
+ # you'll want to use the multiline codec or filter.
16
20
  #
17
21
  # The plugin aims to track changing files and emit new content as it's
18
22
  # appended to each file. It's not well-suited for reading a file from
@@ -170,6 +174,9 @@ class LogStash::Inputs::File < LogStash::Inputs::Base
170
174
  require "digest/md5"
171
175
  @logger.info("Registering file input", :path => @path)
172
176
  @host = Socket.gethostname.force_encoding(Encoding::UTF_8)
177
+ # This check is Logstash 5 specific. If the class does not exist, and it
178
+ # won't in older versions of Logstash, then we need to set it to nil.
179
+ settings = defined?(LogStash::SETTINGS) ? LogStash::SETTINGS : nil
173
180
 
174
181
  @tail_config = {
175
182
  :exclude => @exclude,
@@ -189,6 +196,17 @@ class LogStash::Inputs::File < LogStash::Inputs::Base
189
196
  end
190
197
 
191
198
  if @sincedb_path.nil?
199
+ if settings
200
+ datapath = File.join(settings.get_value("path.data"), "plugins", "inputs", "file")
201
+ # Ensure that the filepath exists before writing, since it's deeply nested.
202
+ FileUtils::mkdir_p datapath
203
+ @sincedb_path = File.join(datapath, ".sincedb_" + Digest::MD5.hexdigest(@path.join(",")))
204
+ end
205
+ end
206
+
207
+ # This section is going to be deprecated eventually, as path.data will be
208
+ # the default, not an environment variable (SINCEDB_DIR or HOME)
209
+ if @sincedb_path.nil? # If it is _still_ nil...
192
210
  if ENV["SINCEDB_DIR"].nil? && ENV["HOME"].nil?
193
211
  @logger.error("No SINCEDB_DIR or HOME environment variable set, I don't know where " \
194
212
  "to keep track of the files I'm watching. Either set " \
@@ -296,6 +314,7 @@ class LogStash::Inputs::File < LogStash::Inputs::Base
296
314
  end # def run
297
315
 
298
316
  def post_process_this(event)
317
+ event.set("[@metadata][host]", @host)
299
318
  event.set("host", @host) if !event.include?("host")
300
319
  decorate(event)
301
320
  @queue << event
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-file'
4
- s.version = '3.0.3'
4
+ s.version = '3.1.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Stream events from files."
7
7
  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"
@@ -32,4 +32,3 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency 'logstash-codec-json'
33
33
  s.add_development_dependency 'rspec-sequencing'
34
34
  end
35
-
@@ -122,9 +122,11 @@ describe LogStash::Inputs::File do
122
122
 
123
123
  insist { events[0].get("path") } == "my_path"
124
124
  insist { events[0].get("host") } == "my_host"
125
+ insist { events[0].get("[@metadata][host]") } == "#{Socket.gethostname.force_encoding(Encoding::UTF_8)}"
125
126
 
126
127
  insist { events[1].get("path") } == "#{tmpfile_path}"
127
128
  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)}"
128
130
  end
129
131
 
130
132
  context "when sincedb_path is an existing directory" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project:
189
- rubygems_version: 2.6.3
189
+ rubygems_version: 2.4.8
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Stream events from files.