From bf5875c3dcd0f44811d6d37802ac8200d1871638 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 26 Jan 2019 23:47:42 +0500 Subject: [PATCH] Agent: Add support for get metrics --- consul/base.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/consul/base.py b/consul/base.py index ee6ab254..47dd6453 100755 --- a/consul/base.py +++ b/consul/base.py @@ -806,6 +806,18 @@ def force_leave(self, node): return self.agent.http.put( CB.bool(), '/v1/agent/force-leave/%s' % node) + def metrics(self, token=None): + """ + Returns dump of the metrics for the most recent finished interval + """ + params = [] + token = token or self.agent.token + if token: + params.append(('token', token)) + return self.agent.http.get( + CB.json(), '/v1/agent/metrics', + params=params) + class Service(object): def __init__(self, agent): self.agent = agent