lib/logstash/inputs/yasuri.rb in logstash-input-yasuri-5.0.3 vs lib/logstash/inputs/yasuri.rb in logstash-input-yasuri-5.0.4
- old
+ new
@@ -8,14 +8,20 @@
class LogStash::Inputs::Yasuri < LogStash::Inputs::Base
config_name "yasuri"
default :codec, "plain"
+ # logstash-input-yasuri require option :parse_tree or :parse_tree_path.
+ # If given both, logstash-input-yasuri use :parse_tree.
+
# Parse tree as JSON.
# Read https://github.com/tac0x2a/yasuri/blob/master/USAGE.md#construct-parse-tree
config :parse_tree, :validate => :string
+ # Path to parse tree JSON file.
+ config :parse_tree_path, :validate => :string
+
# Target web page url.
config :url, :validate => :string
# Split each results to individual events (struct or pages)
config :split, :default => false
@@ -24,10 +30,14 @@
public
def register
@host = Socket.gethostname
@agent = Mechanize.new
- @tree = Yasuri.json2tree(@parse_tree)
+
+ # If given both, logstash-input-yasuri use :parse_tree.
+ tree = @parse_tree || File.read(@parse_tree_path)
+
+ @tree = Yasuri.json2tree(tree)
end # def register
def run(queue)
# we can abort the loop if stop? becomes true
while !stop?