mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Accept file and http URI in the -f
flag.
This patch was slightly modified to make it merge correctly against master (original patch by @jsvd is #1873) Closes #1873
This commit is contained in:
parent
8be99c4302
commit
fd621fe3d1
2 changed files with 31 additions and 1 deletions
|
@ -2,7 +2,8 @@
|
|||
require "clamp" # gem 'clamp'
|
||||
require "logstash/environment"
|
||||
require "logstash/errors"
|
||||
require "logstash/environment"
|
||||
require "uri"
|
||||
require "net/http"
|
||||
LogStash::Environment.load_locale!
|
||||
|
||||
class LogStash::Agent < Clamp::Command
|
||||
|
@ -286,6 +287,21 @@ class LogStash::Agent < Clamp::Command
|
|||
end # def configure_plugin_path
|
||||
|
||||
def load_config(path)
|
||||
|
||||
uri = URI.parse(path)
|
||||
case uri.scheme
|
||||
when nil then
|
||||
local_config(path)
|
||||
when /http/ then
|
||||
fetch_config(uri)
|
||||
when "file" then
|
||||
local_config(uri.path)
|
||||
else
|
||||
fail(I18n.t("logstash.agent.configuration.scheme-not-supported", :path => path))
|
||||
end
|
||||
end
|
||||
|
||||
def local_config(path)
|
||||
path = File.join(path, "*") if File.directory?(path)
|
||||
|
||||
if Dir.glob(path).length == 0
|
||||
|
@ -305,4 +321,12 @@ class LogStash::Agent < Clamp::Command
|
|||
return config
|
||||
end # def load_config
|
||||
|
||||
def fetch_config(uri)
|
||||
begin
|
||||
Net::HTTP.get(uri) + "\n"
|
||||
rescue Exception => e
|
||||
fail(I18n.t("logstash.agent.configuration.fetch-failed", :path => uri.to_s, :message => e.message))
|
||||
end
|
||||
end
|
||||
|
||||
end # class LogStash::Agent
|
||||
|
|
|
@ -69,6 +69,12 @@ en:
|
|||
file-not-found: |-
|
||||
No config files found: %{path}
|
||||
Can you make sure this path is a logstash config file?
|
||||
scheme-not-supported: |-
|
||||
URI scheme not supported: %{path}
|
||||
Either pass a local file path or "file|http://" URI
|
||||
fetch-failed: |-
|
||||
Unable to fetch config from: %{path}
|
||||
Reason: %{message}
|
||||
setting_missing: |-
|
||||
Missing a required setting for the %{plugin} %{type} plugin:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue