From ae7ecdd7814a859869ced44067c4960cd80b41ac Mon Sep 17 00:00:00 2001 From: Andrew DePaula <39636957+voyager131@users.noreply.github.com> Date: Sun, 12 May 2019 13:10:09 -0700 Subject: [PATCH 1/3] Update http_poller.rb --- lib/logstash/inputs/http_poller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/logstash/inputs/http_poller.rb b/lib/logstash/inputs/http_poller.rb index 9b814b1..8059e29 100644 --- a/lib/logstash/inputs/http_poller.rb +++ b/lib/logstash/inputs/http_poller.rb @@ -59,6 +59,11 @@ def setup_requests! def normalize_request(url_or_spec) if url_or_spec.is_a?(String) res = [:get, url_or_spec] + #substitute date variables if passed as part of the URL string + now_datetime = DateTime.now + res.gsub!(/{{%y}}/, now_datetime.year) + res.gsub!(/{{%m}}/, now_datetime.month) + elsif url_or_spec.is_a?(Hash) # The client will expect keys / values spec = Hash[url_or_spec.clone.map {|k,v| [k.to_sym, v] }] # symbolize keys From 5a99149f19462ddbd81d060fcea6881891044ac3 Mon Sep 17 00:00:00 2001 From: Andrew DePaula <39636957+voyager131@users.noreply.github.com> Date: Sun, 12 May 2019 13:15:05 -0700 Subject: [PATCH 2/3] Update http_poller.rb --- lib/logstash/inputs/http_poller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logstash/inputs/http_poller.rb b/lib/logstash/inputs/http_poller.rb index 8059e29..667648e 100644 --- a/lib/logstash/inputs/http_poller.rb +++ b/lib/logstash/inputs/http_poller.rb @@ -6,10 +6,10 @@ require "manticore" require "rufus/scheduler" -class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base +class LogStash::Inputs::HTTP_Poller2 < LogStash::Inputs::Base include LogStash::PluginMixins::HttpClient - config_name "http_poller" + config_name "http_poller2" default :codec, "json" @@ -40,7 +40,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base def register @host = Socket.gethostname.force_encoding(Encoding::UTF_8) - @logger.info("Registering http_poller Input", :type => @type, :schedule => @schedule, :timeout => @timeout) + @logger.info("Registering http_poller2 Input", :type => @type, :schedule => @schedule, :timeout => @timeout) setup_requests! end From 545e34a8e4aaaa4595b5fd6debba3db9572e80ec Mon Sep 17 00:00:00 2001 From: Andrew DePaula <39636957+voyager131@users.noreply.github.com> Date: Sun, 12 May 2019 13:16:58 -0700 Subject: [PATCH 3/3] Update http_poller_spec.rb --- spec/inputs/http_poller_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/inputs/http_poller_spec.rb b/spec/inputs/http_poller_spec.rb index 9543219..603e8ed 100644 --- a/spec/inputs/http_poller_spec.rb +++ b/spec/inputs/http_poller_spec.rb @@ -5,7 +5,7 @@ # Workaround for the bug reported in https://github.com/jruby/jruby/issues/4637 require 'rspec/matchers/built_in/raise_error.rb' -describe LogStash::Inputs::HTTP_Poller do +describe LogStash::Inputs::HTTP_Poller2 do let(:metadata_target) { "_http_poller_metadata" } let(:queue) { Queue.new } let(:default_schedule) { @@ -26,7 +26,7 @@ "metadata_target" => metadata_target } } - let(:klass) { LogStash::Inputs::HTTP_Poller } + let(:klass) { LogStash::Inputs::HTTP_Poller2 } describe "instances" do subject { klass.new(default_opts) } @@ -305,7 +305,7 @@ } shared_examples "unprocessable_requests" do - let(:poller) { LogStash::Inputs::HTTP_Poller.new(settings) } + let(:poller) { LogStash::Inputs::HTTP_Poller2.new(settings) } subject(:event) { poller.send(:run_once, queue) queue.pop(true)