Mark Bergsma has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371117 )

Change subject: Add monitoring specific metric to IdleConnection
......................................................................

Add monitoring specific metric to IdleConnection

pybal_monitor_idleconnection_connections_failed_total counts connections
failing to establish.
pybal_monitor_idleconnection_connections_lost_total counts connections
lost for unclean reasons.

Bug: T171710
Change-Id: I9acbcd2c859cc9213e40b7f7019a85be49ca72f8
---
M pybal/monitors/idleconnection.py
1 file changed, 31 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/17/371117/1

diff --git a/pybal/monitors/idleconnection.py b/pybal/monitors/idleconnection.py
index 16bde75..04f6dc3 100644
--- a/pybal/monitors/idleconnection.py
+++ b/pybal/monitors/idleconnection.py
@@ -6,6 +6,7 @@
 """
 
 from pybal import monitor, util
+from pybal.metrics import Counter
 
 from twisted.internet import reactor, protocol
 import logging
@@ -31,6 +32,26 @@
     KEEPALIVE_INTERVAL = 30
 
     __name__ = 'IdleConnection'
+
+    metric_labelnames = ('service', 'host', 'monitor')
+    metric_keywords = {
+        'namespace': 'pybal',
+        'subsystem': 'monitor_' + __name__.lower()
+    }
+
+    idleconnection_metrics = {
+        'connections_failed_total': Counter(
+            'connections_failed_total',
+            'Connections failed to establish',
+            labelnames=metric_labelnames + ('reason',),
+            **metric_keywords),
+        'connections_lost_total': Counter(
+            'connections_lost_total',
+            'Connections lost uncleanly',
+            labelnames=metric_labelnames + ('reason',),
+            **metric_keywords)
+    }
+
 
     def __init__(self, coordinator, server, configuration):
         """Constructor"""
@@ -76,6 +97,11 @@
 
         self.report("%s failed." % self._report_prefix(), level=logging.WARN)
 
+        self.idleconnection_metrics['connections_failed_total'].labels(
+            reason=reason.type.__name__,
+            **self.metric_labels
+            ).inc()
+
         # Slowly reconnect
         self.retry(connector)
 
@@ -95,6 +121,11 @@
 
             self.report("%s lost." % self._report_prefix(), level=logging.INFO)
 
+            self.idleconnection_metrics['connections_lost_total'].labels(
+                reason=reason.type.__name__,
+                **self.metric_labels
+                ).inc()
+
             # Slowly reconnect
             self.retry(connector)
 

-- 
To view, visit https://gerrit.wikimedia.org/r/371117
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9acbcd2c859cc9213e40b7f7019a85be49ca72f8
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to