From adfd06fbf80d9d12065bc7bb8903cb1c784fab60 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Fri, 22 Apr 2016 10:39:08 +0200 Subject: [PATCH] start prometheus pushgateway --- src/emuvim/cli/monitor.py | 2 +- src/emuvim/dcemulator/monitoring.py | 19 +++++++++++++++++++ src/emuvim/dcemulator/prometheus.yml | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/emuvim/cli/monitor.py b/src/emuvim/cli/monitor.py index 040fa13..55e08f0 100755 --- a/src/emuvim/cli/monitor.py +++ b/src/emuvim/cli/monitor.py @@ -1,5 +1,5 @@ """ -son-emu network CLI +son-emu monitor CLI (c) 2016 by Manuel Peuster """ diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index 82411fd..76f67ba 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -61,6 +61,7 @@ class DCNetworkMonitor(): self.monitor_thread.start() # helper tools + self.pushgateway_process = self.start_PushGateway() self.prometheus_process = self.start_Prometheus() self.cadvisor_process = self.start_cadvisor() @@ -228,6 +229,18 @@ class DCNetworkMonitor(): logging.info('Start Prometheus container {0}'.format(cmd)) return Popen(cmd) + def start_PushGateway(self, port=9091): + cmd = ["docker", + "run", + "-d", + "-p", "{0}:9091".format(port), + "--name", "pushgateway", + "prom/pushgateway" + ] + + logging.info('Start Prometheus Push Gateway container {0}'.format(cmd)) + return Popen(cmd) + def start_cadvisor(self, port=8090): cmd = ["docker", "run", @@ -254,6 +267,12 @@ class DCNetworkMonitor(): self.prometheus_process.kill() self._stop_container('prometheus') + if self.pushgateway_process is not None: + logging.info('stopping pushgateway container') + self.pushgateway_process.terminate() + self.pushgateway_process.kill() + self._stop_container('pushgateway') + if self.cadvisor_process is not None: logging.info('stopping cadvisor container') self.cadvisor_process.terminate() diff --git a/src/emuvim/dcemulator/prometheus.yml b/src/emuvim/dcemulator/prometheus.yml index b063d56..4db5b6f 100644 --- a/src/emuvim/dcemulator/prometheus.yml +++ b/src/emuvim/dcemulator/prometheus.yml @@ -34,4 +34,12 @@ scrape_configs: target_groups: - targets: ['172.17.0.1:8090'] + - job_name: 'PushGateway' + + # Override the global default and scrape targets from this job every 5 seconds. + scrape_interval: 5s + + target_groups: + - targets: ['172.17.0.1:9091'] + -- 2.25.1