Add metrics
This PR adds metrics for additional information :
- If a node or cluster is pending restart,
- If the cluster management is paused.
This may be useful for Prometheus/Grafana monitoring.
Close
@@ -293,6 +293,16 @@ class RestApiHandler(BaseHTTPRequestHandler):
metrics.append("# TYPE patroni_dcs_last_seen gauge")
metrics.append("patroni_dcs_last_seen{0} {1}".format(scope_label, postgres.get('dcs_last_seen', 0)))
+ metrics.append("# HELP patroni_pending_restart Value is 1 if the node needs a restart, 0 otherwise.")
+ metrics.append("# TYPE patroni_pending_restart gauge")
+ metrics.append("patroni_pending_restart{0} {1}"
+ .format(scope_label, int(patroni.postgresql.pending_restart)))
+
+ metrics.append("# HELP patroni_is_paused Value is 1 if auto failover is disabled, 0 otherwise.")
+ metrics.append("# TYPE patroni_is_paused gauge")
+ metrics.append("patroni_is_paused{0} {1}"
+ .format(scope_label, int(patroni.ha.is_paused())))
+
self._write_response(200, '\n'.join(metrics)+'\n', content_type='text/plain')
def _read_json_content(self, body_is_optional=False):
