Sha256: adf7dafbce832574fbe0f89b0672cff961d30e7c913c65f48896bbc83a9470b0

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'fluent/plugin/output'
require 'fluent/plugin/prometheus'

module Fluent::Plugin
  class PrometheusOutput < Fluent::Plugin::Output
    Fluent::Plugin.register_output('prometheus', self)
    include Fluent::Plugin::PrometheusLabelParser
    include Fluent::Plugin::Prometheus

    helpers :thread

    def initialize
      super
      @registry = ::Prometheus::Client.registry
    end

    def multi_workers_ready?
      true
    end

    def configure(conf)
      super
      labels = parse_labels_elements(conf)
      @metrics = Fluent::Plugin::Prometheus.parse_metrics_elements(conf, @registry, labels)
    end

    def start
      super
      Fluent::Plugin::Prometheus.start_retention_threads(
        @metrics,
        @registry,
        method(:thread_create),
        method(:thread_current_running?),
        @log
      )
      Fluent::Plugin::Prometheus.start_reset_threads(
        @metrics,
        @registry,
        method(:thread_create),
        method(:thread_current_running?),
        @log
      )
    end

    def process(tag, es)
      instrument(tag, es, @metrics)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phihos-fluent-plugin-prometheus-2.0.3.pre.1 lib/fluent/plugin/out_prometheus.rb