Skip to content

Commit

Permalink
Merge branch 'master' into api-update
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarashit authored Dec 17, 2020
2 parents cafd4e0 + 1783faf commit 0bef95b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions delfin/exporter/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def push_to_prometheus(self, storage_metrics):
labels = metric.labels
values = metric.values
storage_id = labels.get('storage_id')
storage_name = labels.get('name')
storage_sn = labels.get('serial_number')
resource_type = labels.get('resource_type')
unit = unit_of_metric.get(name)
value_type = labels.get('value_type', 'gauge')
storage_labels = (
"storage_id=\"%s\",resource_type=\"%s\","
"storage_id=\"%s\",storage_name=\"%s\",storage_sn=\"%s\","
"resource_type=\"%s\", "
"type=\"%s\",unit=\"%s\",value_type=\"%s\"" %
(storage_id, resource_type, 'RAW', unit, value_type))
(storage_id, storage_name, storage_sn, resource_type,
'RAW', unit, value_type))

self._write_to_prometheus_format(f, name, storage_labels,
values)
12 changes: 12 additions & 0 deletions delfin/task_manager/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ def collect(self):
array_metrics = self.driver_api.collect_array_metrics(
self.context, self.storage_id, self.interval,
self.is_historic)
# fill extra labels to metric by fetching metadata from resource DB
try:
array_details = db.storage_get(self.context, storage_id=self
.storage_id)
for m in array_metrics:
m.labels["name"] = array_details.name
m.labels["serial_number"] = array_details.serial_number

except Exception as e:
msg = _('Failed to add extra labels to array performance '
'metrics: {0}'.format(e))
LOG.error(msg)

self.perf_exporter.dispatch(self.context, array_metrics)

Expand Down

0 comments on commit 0bef95b

Please sign in to comment.