class SemanticLogger::Appender::SplunkHttp
def call(log, logger)
For splunk format requirements see:
Returns [String] JSON to send to Splunk.
def call(log, logger) h = SemanticLogger::Formatters::Raw.new(time_format: :seconds).call(log, logger) h.delete(:host) message = { source: logger.application, host: logger.host, time: h.delete(:time), event: h } message[:sourcetype] = source_type if source_type message[:index] = index if index message.to_json end
def initialize(token: nil,
Proc: Only include log messages where the supplied Proc returns true
regular expression. All other messages will be ignored.
RegExp: Only include log messages where the class name matches the supplied.
filter: [Regexp|Proc]
Default: Use the built-in formatter (See: #call)
the output from this appender
An instance of a class that implements #call, or a Proc to be used to format
formatter: [Object|Proc]
Default: SemanticLogger.default_level
Override the log level for this appender.
level: [:trace | :debug | :info | :warn | :error | :fatal]
ssl_version, use_ssl, verify_callback, verify_depth and verify_mode.
ca_file, ca_path, cert, cert_store, ciphers, key, open_timeout, read_timeout, ssl_timeout,
Specific SSL options: For more details see NET::HTTP.start
ssl: [Hash]
Default: true
Splunk supports HTTP Compression, enable by default.
compress: [true|false]
Default: SemanticLogger.host
Name of this host to appear in log messages.
host: [String]
Default: SemanticLogger.application
Name of this application to appear in log messages.
application: [String]
verify_mode will default: OpenSSL::SSL::VERIFY_PEER
Example: https://example.com
To enable SSL include https in the URL.
Example: http://example.com
Valid URL to post to.
url: [String]
Optional: Name of a valid index for this message in Splunk.
index: [String]
Optional: Source type to display in Splunk
source_type: [String]
Mandatory.
Token created in Splunk for this HTTP Appender
token: [String]
Parameters:
Create Splunk appender over persistent HTTP(S)
def initialize(token: nil, source_type: nil, index: nil, compress: true, **args, &block) @source_type = source_type @index = index super(compress: compress, **args, &block) # Put splunk auth token in the header of every HTTP post. @header["Authorization"] = "Splunk #{token}" end