@@ -251,11 +251,11 @@ module Agents |
||
251 | 251 |
check_urls(interpolated['url']) |
252 | 252 |
end |
253 | 253 |
|
254 |
- def check_urls(in_url) |
|
254 |
+ def check_urls(in_url, payload = {}) |
|
255 | 255 |
return unless in_url.present? |
256 | 256 |
|
257 | 257 |
Array(in_url).each do |url| |
258 |
- check_url(url) |
|
258 |
+ check_url(url, payload) |
|
259 | 259 |
end |
260 | 260 |
end |
261 | 261 |
|
@@ -322,11 +322,11 @@ module Agents |
||
322 | 322 |
interpolate_with(event) do |
323 | 323 |
url_to_scrape = |
324 | 324 |
if url_template = options['url_from_event'].presence |
325 |
- interpolate_string(url_template) |
|
325 |
+ interpolate_options(url_template) |
|
326 | 326 |
else |
327 | 327 |
event.payload['url'] |
328 | 328 |
end |
329 |
- check_url(url_to_scrape, |
|
329 |
+ check_urls(url_to_scrape, |
|
330 | 330 |
interpolated['mode'].to_s == "merge" ? event.payload : {}) |
331 | 331 |
end |
332 | 332 |
end |
@@ -673,6 +673,19 @@ fire: hot |
||
673 | 673 |
expect(stub).to have_been_requested |
674 | 674 |
end |
675 | 675 |
|
676 |
+ it "should allow url_from_event to be an array of urls" do |
|
677 |
+ stub1 = stub_request(:any, 'http://example.org/?url=http%3A%2F%2Fxkcd.com') |
|
678 |
+ stub2 = stub_request(:any, 'http://google.org/?url=http%3A%2F%2Fxkcd.com') |
|
679 |
+ |
|
680 |
+ @checker.options = @valid_options.merge( |
|
681 |
+ 'url_from_event' => ['http://example.org/?url={{url | uri_escape}}', 'http://google.org/?url={{url | uri_escape}}'] |
|
682 |
+ ) |
|
683 |
+ @checker.receive([@event]) |
|
684 |
+ |
|
685 |
+ expect(stub1).to have_been_requested |
|
686 |
+ expect(stub2).to have_been_requested |
|
687 |
+ end |
|
688 |
+ |
|
676 | 689 |
it "should interpolate values from incoming event payload" do |
677 | 690 |
expect { |
678 | 691 |
@valid_options['extract'] = { |