From 61fd52859c8212626480d66c0795d399be37d0a9 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Fri, 29 Apr 2016 12:41:54 +0200 Subject: [PATCH] update monitoring with prometheus --- src/emuvim/dcemulator/monitoring.py | 5 ++++- src/emuvim/dcemulator/prometheus.yml | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index 54e7986..b3ec7ee 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -246,12 +246,14 @@ class DCNetworkMonitor(): #logging.info('first measurement') time.sleep(1) self.monitor_lock.release() + metric_rate = self.get_network_metrics() return metric_rate + else: time_delta = (port_uptime - metric_dict['previous_monitor_time']) metric_rate = (this_measurement - metric_dict['previous_measurement']) / float(time_delta) - # logging.info('uptime:{2} delta:{0} rate:{1}'.format(time_delta,byte_rate,port_uptime)) + logging.info('metric: {0} rate:{1}'.format(metric_dict['metric_key'], metric_rate)) metric_dict['previous_measurement'] = this_measurement metric_dict['previous_monitor_time'] = port_uptime @@ -274,6 +276,7 @@ class DCNetworkMonitor(): "--rm", "-p", "{0}:9090".format(port), "-v", "{0}/prometheus.yml:/etc/prometheus/prometheus.yml".format(os.path.dirname(os.path.abspath(__file__))), + "-v", "{0}/profile.rules:/etc/prometheus/profile.rules".format(os.path.dirname(os.path.abspath(__file__))), "--name", "prometheus", "prom/prometheus" ] diff --git a/src/emuvim/dcemulator/prometheus.yml b/src/emuvim/dcemulator/prometheus.yml index 4db5b6f..2412f85 100644 --- a/src/emuvim/dcemulator/prometheus.yml +++ b/src/emuvim/dcemulator/prometheus.yml @@ -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: -- 2.25.1