Sha256: 2415ec3859c2ce9397ce7bcddea2702c5bfe86d62e4d5486cbc06a85efe5271d
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
module Splash class LogScanner include Splash::Constants include Splash::Config def initialize @logs_target = get_config.logs @registry = Prometheus::Client.registry @metric = Prometheus::Client::Gauge.new(:logerror, docstring: 'SPLASH metric log error', labels: [:log ]) @registry.register(@metric) end def analyse @logs_target.each do |record| record[:count]=0 if record[:count].nil? record[:status] = :clean if record[:status].nil? if File.exist?(record[:log]) then record[:count] = File.readlines(record[:log]).grep(/#{record[:pattern]}/).size record[:status] = :matched if record[:count] > 0 else record[:status] = :mssing end end end def output return @logs_target end def notify @logs_target.each do |item| @metric.set(item[:count], labels: { log: item[:log] }) end Prometheus::Client::Push.new('Splash').add(@registry) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prometheus-splash-0.0.2 | lib/splash/logs.rb |
prometheus-splash-0.0.1 | lib/splash/logs.rb |