Class: Splash::Logs::LogsNotifier
- Inherits:
-
Object
- Object
- Splash::Logs::LogsNotifier
- 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
-
#initialize(options = {}) ⇒ LogsNotifier
constructor
A new instance of LogsNotifier.
-
#notify ⇒ Bool
send metrics to Prometheus PushGateway.
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(={}) @config = get_config @url = @config.prometheus_pushgateway_url @name = [:name] @missing = [:missing] @lines = [:lines] @errors = [:errors] end |
Instance Method Details
#notify ⇒ Bool
send metrics to Prometheus PushGateway
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 |