From d514389e41556ed23bec66a91f865296d39a5bdc Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 12 Jun 2018 09:46:56 +1000 Subject: [PATCH] Convert haproxy-statsd to a pipeline send By default this sends out each stat in a single UDP packet. I found with the AFS monitoring, blasting these out in very quick succession can result in stats getting lost fairly easily. statsd's pipelines are really designed for this. It batches up all the stats and then sends them out combined in reasonable MTU sized chunks. Change-Id: Ife520d549da3a1a667be15e95a747e313825ac20 --- modules/openstack_project/files/git/haproxy-statsd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/openstack_project/files/git/haproxy-statsd.py b/modules/openstack_project/files/git/haproxy-statsd.py index 514b618c31..73b8cabb58 100644 --- a/modules/openstack_project/files/git/haproxy-statsd.py +++ b/modules/openstack_project/files/git/haproxy-statsd.py @@ -145,12 +145,13 @@ class HAProxy(object): return ret def reportStats(self, stats): + pipe = statsd.pipeline() for row in stats: base = 'haproxy.%s.%s.' % (row['pxname'], row['svname']) for key in GAUGES: value = row[key] if value != '': - statsd.gauge(base + key, int(value)) + pipe.gauge(base + key, int(value)) for key in COUNTERS: metric = base + key newvalue = row[key] @@ -160,8 +161,9 @@ class HAProxy(object): oldvalue = self.prevdata.get(metric) if oldvalue is not None: value = newvalue - oldvalue - statsd.incr(metric, value) + pipe.incr(metric, value) self.prevdata[metric] = newvalue + pipe.send() def run(self): while True: