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

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

Add monitoring specific metric to IdleConnection

Counter connection_failed_total counts connections ending for
unclean reasons.

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


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

diff --git a/pybal/monitors/idleconnection.py b/pybal/monitors/idleconnection.py
index fd105dd..5c40751 100644
--- a/pybal/monitors/idleconnection.py
+++ b/pybal/monitors/idleconnection.py
@@ -6,6 +6,7 @@
 """
 
 from pybal import monitor
+from pybal.metrics import Counter
 
 from twisted.internet import reactor, protocol
 import logging
@@ -30,6 +31,21 @@
     KEEPALIVE_INTERVAL = 30
 
     __name__ = 'IdleConnection'
+
+    metric_labelnames = ('service', 'host', 'monitor')
+    metric_keywords = {
+        'namespace': 'pybal',
+        'subsystem': 'monitor_' + __name__.lower()
+    }
+
+    idleconnection_metrics = {
+        'connection_failed_total': Counter(
+            'connection_failed_total',
+            'HTTP(S) request duration',
+            labelnames=metric_labelnames,
+            **metric_keywords)
+    }
+
 
     def __init__(self, coordinator, server, configuration):
         """Constructor"""
@@ -75,6 +91,10 @@
 
         self.report("%s failed." % self._report_prefix(), level=logging.WARN)
 
+        self.idleconnection_metrics['connection_failed_total'].labels(
+            **self.metric_labels
+            ).inc()
+
         # Slowly reconnect
         self.retry(connector)
 
@@ -94,6 +114,10 @@
 
             self.report("%s lost." % self._report_prefix(), level=logging.INFO)
 
+            self.idleconnection_metrics['connection_failed_total'].labels(
+                **self.metric_labels
+                ).inc()
+
             # Slowly reconnect
             self.retry(connector)
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I07809ba636b02a634e91ec86e12215bc9b8b1ad6
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