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
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:
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
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
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)
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()
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 []
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()
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 []
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
vnfr['member-vnf-index-ref'],
vdu_name,
metric_name,
- metric_value)
+ metric_value,
+ tags
+ )
metrics.append(metric)
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
from osm_mon.collector.metric import Metric
+import logging
+
+log = logging.getLogger(__name__)
class VnfMetric(Metric):
}
if extra_tags:
tags.update(extra_tags)
+ log.debug('Tags: %s', tags)
super().__init__(tags, name, value)