Sha256: fd6cf678aa4dae398ba52f149bf502e3e398957e5290503473c3527a3fa56d2d
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'fluent/plugin/output' require 'fluent/plugin/prometheus' module Fluent::Plugin class PrometheusOutputMetric < Fluent::Plugin::Output Fluent::Plugin.register_output('prometheus_metric', self) include Fluent::Plugin::PrometheusLabelParser def initialize super @registry = ::Prometheus::Client.registry end def multi_workers_ready? true end config_param :key, :string def process(tag, es) # Write out values in event stream to Registry es.each do |time, record| # Create metric if not exists begin desc = "fluentd message stream with tag: ${tag}" gauge = @registry.gauge(tag.to_sym, desc.sub!("${tag}", tag)) rescue ::Prometheus::Client::Registry::AlreadyRegisteredError gauge = @registry.get(tag.to_sym) end value = record[@key] if value # set labels as all elements in message besides the key gauge.set(record.except(@key), value) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-prometheus-smarter-1.8.18 | lib/fluent/plugin/out_prometheus_metric.rb |