start prometheus pushgateway
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 22 Apr 2016 08:39:08 +0000 (10:39 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 22 Apr 2016 08:39:08 +0000 (10:39 +0200)
src/emuvim/cli/monitor.py
src/emuvim/dcemulator/monitoring.py
src/emuvim/dcemulator/prometheus.yml

index 040fa13..55e08f0 100755 (executable)
@@ -1,5 +1,5 @@
 """\r
-son-emu network CLI\r
+son-emu monitor CLI\r
 (c) 2016 by Manuel Peuster <manuel.peuster@upb.de>\r
 """\r
 \r
index 82411fd..76f67ba 100755 (executable)
@@ -61,6 +61,7 @@ class DCNetworkMonitor():
         self.monitor_thread.start()\r
 \r
         # helper tools\r
+        self.pushgateway_process = self.start_PushGateway()\r
         self.prometheus_process = self.start_Prometheus()\r
         self.cadvisor_process = self.start_cadvisor()\r
 \r
@@ -228,6 +229,18 @@ class DCNetworkMonitor():
         logging.info('Start Prometheus container {0}'.format(cmd))\r
         return Popen(cmd)\r
 \r
+    def start_PushGateway(self, port=9091):\r
+        cmd = ["docker",\r
+               "run",\r
+               "-d",\r
+               "-p", "{0}:9091".format(port),\r
+               "--name", "pushgateway",\r
+               "prom/pushgateway"\r
+               ]\r
+\r
+        logging.info('Start Prometheus Push Gateway container {0}'.format(cmd))\r
+        return Popen(cmd)\r
+\r
     def start_cadvisor(self, port=8090):\r
         cmd = ["docker",\r
                "run",\r
@@ -254,6 +267,12 @@ class DCNetworkMonitor():
             self.prometheus_process.kill()\r
             self._stop_container('prometheus')\r
 \r
+        if self.pushgateway_process is not None:\r
+            logging.info('stopping pushgateway container')\r
+            self.pushgateway_process.terminate()\r
+            self.pushgateway_process.kill()\r
+            self._stop_container('pushgateway')\r
+\r
         if self.cadvisor_process is not None:\r
             logging.info('stopping cadvisor container')\r
             self.cadvisor_process.terminate()\r
index b063d56..4db5b6f 100644 (file)
@@ -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']
+