Merge "Adding more labels to Prometheus metrics"
diff --git a/osm_mon/collector/vnf_collectors/juju.py b/osm_mon/collector/vnf_collectors/juju.py
index b8c8b4e..8be9e28 100644
--- a/osm_mon/collector/vnf_collectors/juju.py
+++ b/osm_mon/collector/vnf_collectors/juju.py
@@ -47,6 +47,12 @@
nsr_id = vnfr['nsr-id-ref']
vnf_member_index = vnfr['member-vnf-index-ref']
vnfd = self.common_db.get_vnfd(vnfr['vnfd-id'])
+
+ # Populate extra tags for metrics
+ tags = {}
+ tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+
metrics = []
for vdur in vnfr['vdur']:
# This avoids errors when vdur records have not been completely filled
@@ -69,7 +75,7 @@
for measure in measure_list:
log.debug("Measure: %s", measure)
metric = VnfMetric(nsr_id, vnf_member_index, vdur['name'], measure['key'],
- float(measure['value']))
+ float(measure['value'], tags))
metrics.append(metric)
if 'vnf-configuration' in vnfd and 'metrics' in vnfd['vnf-configuration']:
try:
@@ -83,7 +89,7 @@
for measure_list in measures.values():
for measure in measure_list:
log.debug("Measure: %s", measure)
- metric = VnfMetric(nsr_id, vnf_member_index, '', measure['key'], float(measure['value']))
+ metric = VnfMetric(nsr_id, vnf_member_index, '', measure['key'], float(measure['value'], tags))
metrics.append(metric)
return metrics
diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py
index 8a36a14..a13380a 100644
--- a/osm_mon/collector/vnf_collectors/openstack.py
+++ b/osm_mon/collector/vnf_collectors/openstack.py
@@ -81,6 +81,12 @@
nsr_id = vnfr['nsr-id-ref']
vnf_member_index = vnfr['member-vnf-index-ref']
vnfd = self.common_db.get_vnfd(vnfr['vnfd-id'])
+
+ # Populate extra tags for metrics
+ tags = {}
+ tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+
metrics = []
for vdur in vnfr['vdur']:
# This avoids errors when vdur records have not been completely filled
@@ -107,7 +113,6 @@
value = self.backend.collect_metric(metric_type, openstack_metric_name, resource_id,
interface_name)
if value is not None:
- tags = {}
if interface_name:
tags['interface'] = interface_name
metric = VnfMetric(nsr_id, vnf_member_index, vdur['name'], metric_name, value, tags)
diff --git a/osm_mon/collector/vnf_collectors/vio.py b/osm_mon/collector/vnf_collectors/vio.py
index ada6be6..77129e1 100644
--- a/osm_mon/collector/vnf_collectors/vio.py
+++ b/osm_mon/collector/vnf_collectors/vio.py
@@ -48,6 +48,12 @@
vnfd = self.common_db.get_vnfd(vnfr['vnfd-id'])
vdu_mappings = {}
+ # Populate extra tags for metrics
+ nsr_id = vnfr['nsr-id-ref']
+ tags = {}
+ tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+
# Fetch the list of all known resources from vROPS.
resource_list = self.vrops.get_vm_resource_list_from_vrops()
@@ -76,6 +82,8 @@
if len(vdu_mappings) != 0:
return self.vrops.get_metrics(vdu_mappings=vdu_mappings,
monitoring_params=vdu['monitoring-param'],
- vnfr=vnfr)
+ vnfr=vnfr,
+ tags=tags
+ )
else:
return []
diff --git a/osm_mon/collector/vnf_collectors/vmware.py b/osm_mon/collector/vnf_collectors/vmware.py
index 0070b56..0e76bfd 100644
--- a/osm_mon/collector/vnf_collectors/vmware.py
+++ b/osm_mon/collector/vnf_collectors/vmware.py
@@ -184,6 +184,12 @@
vnfd = self.common_db.get_vnfd(vnfr['vnfd-id'])
vdu_mappings = {}
+ # Populate extra tags for metrics
+ nsr_id = vnfr['nsr-id-ref']
+ tags = {}
+ tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+
# Fetch the list of all known resources from vROPS.
resource_list = self.vrops.get_vm_resource_list_from_vrops()
@@ -218,6 +224,8 @@
if len(vdu_mappings) != 0:
return self.vrops.get_metrics(vdu_mappings=vdu_mappings,
monitoring_params=vdu['monitoring-param'],
- vnfr=vnfr)
+ vnfr=vnfr,
+ tags=tags
+ )
else:
return []
diff --git a/osm_mon/collector/vnf_collectors/vrops/vrops_helper.py b/osm_mon/collector/vnf_collectors/vrops/vrops_helper.py
index 430cf86..75819fc 100644
--- a/osm_mon/collector/vnf_collectors/vrops/vrops_helper.py
+++ b/osm_mon/collector/vnf_collectors/vrops/vrops_helper.py
@@ -82,7 +82,8 @@
def get_metrics(self,
vdu_mappings={},
monitoring_params={},
- vnfr=None):
+ vnfr=None,
+ tags={}):
monitoring_keys = {}
# Collect the names of all the metrics we need to query
@@ -155,7 +156,9 @@
vnfr['member-vnf-index-ref'],
vdu_name,
metric_name,
- metric_value)
+ metric_value,
+ tags
+ )
metrics.append(metric)
diff --git a/osm_mon/collector/vnf_metric.py b/osm_mon/collector/vnf_metric.py
index 92d3905..49e7842 100644
--- a/osm_mon/collector/vnf_metric.py
+++ b/osm_mon/collector/vnf_metric.py
@@ -20,6 +20,9 @@
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
from osm_mon.collector.metric import Metric
+import logging
+
+log = logging.getLogger(__name__)
class VnfMetric(Metric):
@@ -31,4 +34,5 @@
}
if extra_tags:
tags.update(extra_tags)
+ log.debug('Tags: %s', tags)
super().__init__(tags, name, value)