Sha256: 39182da9a434b8cc53783656e8f3277271adf2fde1f3f19c8fe0cb5ba58dd556

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

#
# Copyright 2022- MahithaB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require "fluent/plugin/output"
require_relative 'newrelic_metrics_sender'

module Fluent
  module Plugin
    class JfrogSendMetricsOutput < Fluent::Plugin::Output
      Fluent::Plugin.register_output("jfrog_send_metrics", self)
      helpers :timer
      # `config_param` defines a parameter.
      # You can refer to a parameter like an instance variable e.g. @port.
      # `:default` means that the parameter is optional.
      config_param :target_platform, :string, default: ''
      config_param :apikey, :string, default: ''
      config_param :url, :string, default: 'https://metric-api.newrelic.com/metric/v1'

      # `configure` is called before `start`.
      # 'conf' is a `Hash` that includes the configuration parameters.
      # If the configuration is invalid, raise `Fluent::ConfigError`.
      def configure(conf)
        super
        raise Fluent::ConfigError, 'Must define the vendor to use for getting the metrics.' if @target_platform == ''

        raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''

      end

      def process(tag, es)
        es.each do |time, record|
          if @target_platform == 'NEWRELIC'
            vendor = NewRelicMetrics.new(@apikey, @url)
            vendor.send_metrics(record)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-jfrog-send-metrics-0.1.2 lib/fluent/plugin/out_jfrog_send_metrics.rb
fluent-plugin-jfrog-send-metrics-0.1.1 lib/fluent/plugin/out_jfrog_send_metrics.rb