class LogStash::Outputs::SumoLogic::Monitor
Attributes
is_pile[R]
Public Class Methods
new(queue, stats, config)
click to toggle source
# File lib/logstash/outputs/sumologic/monitor.rb, line 13 def initialize(queue, stats, config) @queue = queue @stats = stats @stopping = Concurrent::AtomicBoolean.new(false) @header_builder = HeaderBuilder.new(config) @enabled = config["stats_enabled"] ||= false @interval = config["stats_interval"] ||= 60 @interval = @interval < 0 ? 0 : @interval end
Public Instance Methods
build_metric_line(key, value, timestamp)
click to toggle source
# File lib/logstash/outputs/sumologic/monitor.rb, line 72 def build_metric_line(key, value, timestamp) "metric=#{key} interval=#{@interval} category=monitor #{value} #{timestamp}" end
build_stats_payload()
click to toggle source
# File lib/logstash/outputs/sumologic/monitor.rb, line 48 def build_stats_payload() timestamp = Time.now().to_i counters = [ "total_input_events", "total_input_bytes", "total_metrics_datapoints", "total_log_lines", "total_output_requests", "total_output_bytes", "total_output_bytes_compressed", "total_response_times", "total_response_success" ].map { |key| value = @stats.send(key).value log_dbg("stats", :key => key, :value => value) build_metric_line(key, value, timestamp) }.join($/) "#{STATS_TAG}#{counters}" end
start()
click to toggle source
# File lib/logstash/outputs/sumologic/monitor.rb, line 24 def start() log_info("starting monitor...", :interval => @interval) @stopping.make_false() if (@enabled) @monitor_t = Thread.new { while @stopping.false? Stud.stoppable_sleep(@interval) { @stopping.true? } if @stats.total_log_lines.value > 0 || @stats.total_metrics_datapoints.value > 0 @queue.enq(Batch.new(@header_builder.build_stats(), build_stats_payload())) end end # while } end # if end
stop()
click to toggle source
# File lib/logstash/outputs/sumologic/monitor.rb, line 39 def stop() @stopping.make_true() if (@enabled) log_info("shutting down monitor...") @monitor_t.join log_info("monitor is fully shutted down") end end