Class: Splash::Logs::LogsNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/splash/logs.rb

Constant Summary collapse

@@registry =
Prometheus::Client::Registry::new
@@metric_missing =
Prometheus::Client::Gauge.new(:logmissing, docstring: 'SPLASH metric log missing', labels: [:log ])
@@metric_count =
Prometheus::Client::Gauge.new(:logerrors, docstring: 'SPLASH metric log error', labels: [:log ])
@@metric_lines =
Prometheus::Client::Gauge.new(:loglines, docstring: 'SPLASH metric log lines numbers', labels: [:log ])

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ LogsNotifier

Returns a new instance of LogsNotifier.



19
20
21
22
23
24
25
26
# File 'lib/splash/logs.rb', line 19

def initialize(options={})
  @config = get_config
  @url = @config.prometheus_pushgateway_url
  @name = options[:name]
  @missing = options[:missing]
  @lines = options[:lines]
  @errors = options[:errors]
end

Instance Method Details

#notifyBool

send metrics to Prometheus PushGateway

Returns:

  • (Bool)


30
31
32
33
34
35
36
37
38
39
# File 'lib/splash/logs.rb', line 30

def notify
  unless verify_service url: @url then
    return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
  end
  @@metric_missing.set(@missing, labels: { log: @name })
  @@metric_count.set(@errors, labels: { log: @name })
  @@metric_lines.set(@lines, labels: { log: @name })
  hostname = Socket.gethostname
  return Prometheus::Client::Push.new("Splash", hostname, @url).add(@@registry)
end