From: stevenvanrossem Date: Fri, 29 Apr 2016 10:41:54 +0000 (+0200) Subject: update monitoring with prometheus X-Git-Tag: v3.1~136^2 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=commitdiff_plain;h=61fd52859c8212626480d66c0795d399be37d0a9 update monitoring with prometheus --- 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: