Class: Fluent::SplunkHECOutput

Inherits:
ObjectBufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_splunk_hec.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

Raises:

  • (ConfigError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 54

def configure(conf)
  super

  if @channel && @auto_generate_channel 
    log.warn "Both channel and auto_generate_channel are set.. ignoring channel param and auto generating channel instead"
  end

  @channel = SecureRandom.uuid if @auto_generate_channel

  raise ConfigError, "'channel' parameter is required when 'use_ack' is true" if @use_ack && !@channel
  raise ConfigError, "'ack_interval' parameter must be a non negative integer" if @use_ack && @ack_interval < 0
  raise ConfigError, "'event_key' parameter is required when 'raw' is true" if @raw && !@event_key
  raise ConfigError, "'channel' parameter is required when 'raw' is true" if @raw && !@channel
  
  @default_sourcetype = @sourcetype if @sourcetype && !@default_sourcetype

  # build hash for query string
  if @raw
    @query = {}
    @query['host'] = @default_host if @default_host
    @query['source'] = @default_source if @default_source
    @query['index'] = @default_index if @default_index
    @query['sourcetype'] = @default_sourcetype if @default_sourcetype
  end
end

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 80

def multi_workers_ready?
  true
end

#shutdownObject



89
90
91
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 89

def shutdown
  super
end

#startObject



84
85
86
87
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 84

def start
  setup_client
  super
end

#use_sslObject

For SSL



47
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 47

config_param :use_ssl, :bool, default: false

#write_objects(_tag, chunk) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 93

def write_objects(_tag, chunk)
  return if chunk.empty?

  payload = ''
  chunk.msgpack_each do |time, record|
    payload << (@raw ? format_event_raw(record) : format_event(time, record))
  end
  post_payload(payload) unless payload.empty?
end