Skip to content

Commit

Permalink
Adding code to check metrics dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
NajmudheenCT committed Jun 18, 2021
1 parent 5db0b48 commit 6a9bbba
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions delfin/exporter/prometheus/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import datetime
import os
import pytz
import six

from oslo_config import cfg
from oslo_log import log
Expand Down Expand Up @@ -63,7 +64,9 @@ def check_metrics_dir_exists(self, directory):
os.makedirs(directory)
return True
except Exception as e:
LOG.error('Error while creating metrics directory')
msg = six.text_type(e)
LOG.error("Error while creating metrics directory. Reason: %s",
msg)
return False

def set_timestamp_offset_from_utc_ms(self):
Expand Down Expand Up @@ -115,20 +118,20 @@ def push_to_prometheus(self, storage_metrics):
resource_type = labels.get('resource_type')
resource_id = labels.get('resource_id')
unit = labels.get('unit')
type = labels.get('type', 'RAW')
m_type = labels.get('type', 'RAW')
value_type = labels.get('value_type', 'gauge')
prom_labels = (
"storage_id=\"%s\","
"storage_name=\"%s\","
"storage_sn=\"%s\","
"resource_type=\"%s\","
"resource_id=\"%s\","
"type=\"%s\","
"unit=\"%s\","
"value_type=\"%s\"" %
(storage_id, storage_name, storage_sn, resource_type,
resource_id,
type, unit, value_type))
"storage_id=\"%s\","
"storage_name=\"%s\","
"storage_sn=\"%s\","
"resource_type=\"%s\","
"resource_id=\"%s\","
"type=\"%s\","
"unit=\"%s\","
"value_type=\"%s\"" %
(storage_id, storage_name, storage_sn, resource_type,
resource_id,
m_type, unit, value_type))
name = labels.get('resource_type') + '_' + name
self._write_to_prometheus_format(f, name, labels, prom_labels,
values)
Expand Down

0 comments on commit 6a9bbba

Please sign in to comment.