@@ -31,11 +31,14 @@ class SplunkHecOutput < SplunkOutput
3131 config_param :protocol , :enum , list : %i[ http https ] , default : :https
3232
3333 desc 'The hostname/IP to HEC, or HEC load balancer.'
34- config_param :hec_host , :string
34+ config_param :hec_host , :string , default : ''
3535
3636 desc 'The port number to HEC, or HEC load balancer.'
3737 config_param :hec_port , :integer , default : 8088
3838
39+ desc 'Full url to connect tosplunk. Example: https://mydomain.com:8088/apps/splunk'
40+ config_param :full_url , :string , default : ''
41+
3942 desc 'The HEC token.'
4043 config_param :hec_token , :string
4144
@@ -132,7 +135,7 @@ def initialize
132135
133136 def configure ( conf )
134137 super
135-
138+ raise Fluent :: ConfigError , 'One of `hec_host` or `full_url` is required.' if @hec_host . empty? && @full_url . empty?
136139 check_metric_configs
137140 pick_custom_format_method
138141 end
@@ -279,9 +282,17 @@ def format_metric(tag, time, record)
279282 end
280283
281284 def construct_api
282- URI ( "#{ @protocol } ://#{ @hec_host } :#{ @hec_port } /services/collector" )
285+ if @full_url . empty?
286+ URI ( "#{ @protocol } ://#{ @hec_host } :#{ @hec_port } /services/collector" )
287+ else
288+ URI ( "#{ @full_url . delete_suffix ( "/" ) } /services/collector" )
289+ end
283290 rescue StandardError
284- raise Fluent ::ConfigError , "hec_host (#{ @hec_host } ) and/or hec_port (#{ @hec_port } ) are invalid."
291+ if @full_url . empty?
292+ raise Fluent ::ConfigError , "hec_host (#{ @hec_host } ) and/or hec_port (#{ @hec_port } ) are invalid."
293+ else
294+ raise Fluent ::ConfigError , "full_url (#{ @full_url } ) is invalid."
295+ end
285296 end
286297
287298 def new_connection
0 commit comments