lib/splash/daemon/metrics.rb in prometheus-splash-0.5.2 vs lib/splash/daemon/metrics.rb in prometheus-splash-0.5.3
- old
+ new
@@ -16,25 +16,30 @@
class Manager
attr_reader :execution_count
- attr_reader :monitoring_count
+ attr_reader :monitoring_logs_count
+ attr_reader :monitoring_processes_count
def initialize
@config = get_config
@starttime = Time.now
@execution_count = 0
- @monitoring_count = 0
+ @monitoring_logs_count = 0
+ @monitoring_processes_count = 0
+
@registry = Prometheus::Client::Registry::new
@metric_uptime = Prometheus::Client::Gauge.new(:splash_uptime, docstring: 'SPLASH self metric uptime')
@metric_execution = Prometheus::Client::Gauge.new(:splash_execution, docstring: 'SPLASH self metric total commands execution count')
- @metric_monitoring = Prometheus::Client::Gauge.new(:splash_monitoring, docstring: 'SPLASH self metric total logs monitoring count')
+ @metric_logs_monitoring = Prometheus::Client::Gauge.new(:splash_logs_monitoring, docstring: 'SPLASH self metric total logs monitoring count')
+ @metric_processes_monitoring = Prometheus::Client::Gauge.new(:splash_processes_monitoring, docstring: 'SPLASH self metric total processes monitoring count')
@registry.register(@metric_uptime)
@registry.register(@metric_execution)
- @registry.register(@metric_monitoring)
+ @registry.register(@metric_logs_monitoring)
+ @registry.register(@metric_processes_monitoring)
end
def uptime
return Time.now - @starttime
@@ -43,14 +48,17 @@
def inc_execution
@execution_count += 1
end
- def inc_monitoring
- @monitoring_count += 1
+ def inc_logs_monitoring
+ @monitoring_logs_count += 1
end
+ def inc_processes_monitoring
+ @monitoring_processes_count += 1
+ end
def notify
log = get_logger
session = get_session
unless verify_service host: @config.prometheus_pushgateway_host ,port: @config.prometheus_pushgateway_port then
@@ -58,10 +66,12 @@
end
log.debug "Sending Splash self metrics to PushGateway." , session
@metric_uptime.set uptime
@metric_execution.set execution_count
- @metric_monitoring.set monitoring_count
+ @metric_logs_monitoring.set monitoring_logs_count
+ @metric_processes_monitoring.set monitoring_processes_count
+
hostname = Socket.gethostname
url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
log.debug "Sending to Prometheus PushGateway done.", session
return {:case => :quiet_exit }