Class: LogStash::Outputs::SumoLogic::HeaderBuilder
- Inherits:
-
Object
- Object
- LogStash::Outputs::SumoLogic::HeaderBuilder
- Includes:
- Common
- Defined in:
- lib/logstash/outputs/sumologic/header_builder.rb
Constant Summary
Constants included from Common
Common::CARBON2, Common::CATEGORY_HEADER, Common::CATEGORY_HEADER_DEFAULT, Common::CLIENT_HEADER, Common::CLIENT_HEADER_VALUE, Common::CONTENT_ENCODING, Common::CONTENT_TYPE, Common::CONTENT_TYPE_CARBON2, Common::CONTENT_TYPE_GRAPHITE, Common::CONTENT_TYPE_LOG, Common::DEFAULT_LOG_FORMAT, Common::DEFLATE, Common::GRAPHITE, Common::GZIP, Common::HOST_HEADER, Common::LOG_TO_CONSOLE, Common::METRICS_NAME_PLACEHOLDER, Common::NAME_HEADER, Common::NAME_HEADER_DEFAULT, Common::STATS_TAG, Common::STOP_TAG
Instance Method Summary collapse
-
#build(event) ⇒ Object
def initialize.
-
#initialize(config) ⇒ HeaderBuilder
constructor
A new instance of HeaderBuilder.
Methods included from Common
#log_dbg, #log_err, #log_info, #log_warn, #set_logger
Constructor Details
#initialize(config) ⇒ HeaderBuilder
Returns a new instance of HeaderBuilder.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/logstash/outputs/sumologic/header_builder.rb', line 10 def initialize(config) @extra_headers = config["extra_headers"] ||= {} @source_category = config["source_category"] ||= CATEGORY_HEADER_DEFAULT @source_host = config["source_host"] ||= Socket.gethostname @source_name = config["source_name"] ||= NAME_HEADER_DEFAULT @metrics = config["metrics"] @fields_as_metrics = config["fields_as_metrics"] @metrics_format = (config["metrics_format"] ||= CARBON2).downcase @compress = config["compress"] @compress_encoding = config["compress_encoding"] end |
Instance Method Details
#build(event) ⇒ Object
def initialize
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/logstash/outputs/sumologic/header_builder.rb', line 24 def build(event) headers = Hash.new headers.merge!(@extra_headers) headers[CLIENT_HEADER] = CLIENT_HEADER_VALUE headers[CATEGORY_HEADER] = event.sprintf(@source_category) unless @source_category.blank? headers[HOST_HEADER] = event.sprintf(@source_host) unless @source_host.blank? headers[NAME_HEADER] = event.sprintf(@source_name) unless @source_name.blank? append_content_header(headers) append_compress_header(headers) headers end |