Class: MtrMonitor::LogDna

Inherits:
Object
  • Object
show all
Defined in:
lib/mtr_monitor/log_dna.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_name, logdna_ingestion_key, local_log_path, host_ip_address, s3_url, hostname, logger) ⇒ LogDna

Returns a new instance of LogDna.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mtr_monitor/log_dna.rb', line 8

def initialize(route_name, logdna_ingestion_key, local_log_path, host_ip_address, s3_url, hostname, logger)
  config = {
    :ip => host_ip_address,
    :app => "mtr-monitor",
    :level => "INFO"
  }

  @route_name = route_name
  @s3_url     = s3_url
  @hostname   = hostname

  @mtr_log = File.read(local_log_path)
  @logdna  = Logdna::Ruby.new(logdna_ingestion_key, config)
  @logger  = logger
end

Class Method Details

.submit(*args) ⇒ Object



4
5
6
# File 'lib/mtr_monitor/log_dna.rb', line 4

def self.submit(*args)
  new(*args).submit
end

Instance Method Details

#submitObject



24
25
26
27
28
29
# File 'lib/mtr_monitor/log_dna.rb', line 24

def submit
  msg = "Route: #{@route_name}, Host: #{@hostname}, Tier1: #{tier1_provider}, s3: #{@s3_url}"

  @logdna.log(msg)
  @logger.info("Emitted to LogDNA: #{msg}")
end