Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/fluent/plugin/out_splunk.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# frozen_string_literal: true

require 'fluent/output'
require 'fluent/plugin/output'
require 'fluent/plugin/formatter'
require 'prometheus/client'
require 'benchmark'

module Fluent::Plugin
class SplunkOutput < Fluent::BufferedOutput
class SplunkOutput < Fluent::Plugin::Output
helpers :formatter

autoload :VERSION, 'fluent/plugin/out_splunk/version'
Expand Down Expand Up @@ -100,9 +99,9 @@ def write(chunk)
write_to_splunk(chunk)
end

@metrics[:record_counter].increment(labels: metric_labels, by: chunk.size_of_events)
@metrics[:record_counter].increment(labels: metric_labels, by: chunk.size)
@metrics[:bytes_counter].increment(labels: metric_labels, by: chunk.bytesize)
@metrics[:write_records_histogram].observe(chunk.size_of_events, labels: metric_labels)
@metrics[:write_records_histogram].observe(chunk.size, labels: metric_labels)
@metrics[:write_bytes_histogram].observe(chunk.bytesize, labels: metric_labels, )
@metrics[:write_latency_histogram].observe(t, labels: metric_labels, )
end
Expand Down
4 changes: 4 additions & 0 deletions lib/fluent/plugin/out_splunk_hec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def configure(conf)
pick_custom_format_method
end

def write(chunk)
super
end

def start
super
@conn = Net::HTTP::Persistent.new.tap do |c|
Expand Down
6 changes: 5 additions & 1 deletion lib/fluent/plugin/out_splunk_ingest_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def configure(conf)
super
end

def write(chunk)
super
end

def construct_api
uri = "https://#{@ingest_api_host}/#{@ingest_api_tenant}#{@ingest_api_events_endpoint}"
URI(uri)
Expand Down Expand Up @@ -101,7 +105,7 @@ def new_connection
end

def write_to_splunk(chunk)
log.trace "#{self.class}: In write() with #{chunk.size_of_events} records and #{chunk.bytesize} bytes "
log.trace "#{self.class}: In write() with #{chunk.size} records and #{chunk.bytesize} bytes "
# ingest API is an array of json objects
body = "[#{chunk.read.chomp(',')}]"
@conn ||= new_connection
Expand Down