update monitoring with prometheus
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 29 Apr 2016 10:41:54 +0000 (12:41 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 29 Apr 2016 10:41:54 +0000 (12:41 +0200)
src/emuvim/dcemulator/monitoring.py
src/emuvim/dcemulator/prometheus.yml

index 54e7986..b3ec7ee 100755 (executable)
@@ -246,12 +246,14 @@ class DCNetworkMonitor():
                     #logging.info('first measurement')\r
                     time.sleep(1)\r
                     self.monitor_lock.release()\r
+\r
                     metric_rate = self.get_network_metrics()\r
                     return metric_rate\r
+\r
                 else:\r
                     time_delta = (port_uptime - metric_dict['previous_monitor_time'])\r
                     metric_rate = (this_measurement - metric_dict['previous_measurement']) / float(time_delta)\r
-                    # logging.info('uptime:{2} delta:{0} rate:{1}'.format(time_delta,byte_rate,port_uptime))\r
+                    logging.info('metric: {0} rate:{1}'.format(metric_dict['metric_key'], metric_rate))\r
 \r
                 metric_dict['previous_measurement'] = this_measurement\r
                 metric_dict['previous_monitor_time'] = port_uptime\r
@@ -274,6 +276,7 @@ class DCNetworkMonitor():
                "--rm",\r
                "-p", "{0}:9090".format(port),\r
                "-v", "{0}/prometheus.yml:/etc/prometheus/prometheus.yml".format(os.path.dirname(os.path.abspath(__file__))),\r
+               "-v", "{0}/profile.rules:/etc/prometheus/profile.rules".format(os.path.dirname(os.path.abspath(__file__))),\r
                "--name", "prometheus",\r
                "prom/prometheus"\r
                ]\r
index 4db5b6f..2412f85 100644 (file)
@@ -1,11 +1,16 @@
 global:
   scrape_interval:     15s # By default, scrape targets every 15 seconds.
+  evaluation_interval: 5s
 
   # Attach these labels to any time series or alerts when communicating with
   # external systems (federation, remote storage, Alertmanager).
   external_labels:
     monitor: 'codelab-monitor'
 
+# Rule files specifies a list of files from which rules are read.
+rule_files:
+  - 'profile.rules'
+
 # A scrape configuration containing exactly one endpoint to scrape:
 # Here it's Prometheus itself.
 scrape_configs: