class Fluent::Plugin::JfrogMetricsInput
Public Instance Methods
configure(conf)
click to toggle source
‘configure` is called before `start`. ’conf’ is a ‘Hash` that includes the configuration parameters. If the configuration is invalid, raise `Fluent::ConfigError`.
Calls superclass method
# File lib/fluent/plugin/in_jfrog_metrics.rb, line 47 def configure(conf) super raise Fluent::ConfigError, 'Must define the tag for metrics data.' if @tag == '' raise Fluent::ConfigError, 'Must define the jpd_url to scrape metrics.' if @jpd_url == '' raise Fluent::ConfigError, 'Must define the username for authentication.' if @username == '' raise Fluent::ConfigError, 'Must define the apikey or token for authentication.' if @token == '' && @apikey == '' raise Fluent::ConfigError, 'Must define the interval to use for gathering the metrics.' if @interval == '' raise Fluent::ConfigError, 'Must define the metric_prefix to use for getting the metrics.' if @metric_prefix == '' raise Fluent::ConfigError, 'Must define the vendor to use for getting the metrics.' if @target_platform == '' end
do_execute()
click to toggle source
# File lib/fluent/plugin/in_jfrog_metrics.rb, line 86 def do_execute puts('Executing metrics collection') metrics_helper = MetricsHelper.new(@metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd) platform_metrics = metrics_helper.get_metrics additional_metrics = metrics_helper.get_additional_metrics if !additional_metrics.nil? && additional_metrics != '' platform_metrics += additional_metrics.to_s end if @target_platform == 'SPLUNK' parser = SplunkMetricsParser.new(@metric_prefix, router, @tag) elsif @target_platform == 'ELASTIC' parser = ElasticMetricsParser.new(@metric_prefix, router, @tag) elsif @target_platform == 'NEWRELIC' parser = NewRelicMetricsParser.new(@metric_prefix, router, @tag) else raise 'Parser Type is not valid.Should be SPLUNK or ELASTIC or NEWRELIC' end parser.emit_parsed_metrics(platform_metrics) end
run()
click to toggle source
# File lib/fluent/plugin/in_jfrog_metrics.rb, line 77 def run puts('Preparing metrics collection, creating timer task') timer_task = Concurrent::TimerTask.new(execution_interval: @interval, timeout_interval: 30, run_now: true) do puts('Timer task execution') do_execute end timer_task.execute end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_jfrog_metrics.rb, line 71 def shutdown @running = false @thread.join super end
start()
click to toggle source
‘start` is called when starting and after `configure` is successfully completed.
Calls superclass method
# File lib/fluent/plugin/in_jfrog_metrics.rb, line 65 def start super @running = true @thread = Thread.new(&method(:run)) end