Skip to content

Commit

Permalink
Add "Unit" in metric map report (as per pull request awslabs#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
berenddeboer committed Apr 10, 2020
1 parent f8514b8 commit 88222b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/cloudwatch/modules/client/querystringbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class QuerystringBuilder(object):
_METRIC_NAME_KEY = "MetricName"
_NAME_KEY = "Name"
_VALUE_KEY = "Value"
_UNIT_KEY = "Unit"
_TIMESTAMP_KEY = "Timestamp"
_STATISTICS_KEY = "StatisticValues."
_STAT_MAX = _STATISTICS_KEY + "Maximum"
Expand Down Expand Up @@ -60,6 +61,7 @@ def _build_metric_map(self, metric_list):
metric_map[metric_prefix + self._STORAGE_RESOLUTION] = "1"
self._add_dimensions(metric, metric_map, metric_prefix)
self._add_values(metric, metric_map, metric_prefix)
self._add_unit(metric, metric_map, metric_prefix)
metric_index += 1
return metric_map

Expand All @@ -80,3 +82,6 @@ def _add_values(self, metric, metric_map, metric_prefix):
metric_map[metric_prefix + self._STAT_MIN] = metric.statistics.min
metric_map[metric_prefix + self._STAT_SUM] = metric.statistics.sum
metric_map[metric_prefix + self._STAT_SAMPLE] = metric.statistics.sample_count

def _add_unit(self, metric, metric_map, metric_prefix):
metric_map[metric_prefix + self._UNIT_KEY] = metric.unit
2 changes: 1 addition & 1 deletion src/cloudwatch/modules/metricdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, config_helper, vl, adjusted_time=None):

def build(self):
""" Builds metric data object with name and dimensions but without value or statistics """
metric_array = [MetricDataStatistic(metric_name=self._build_metric_name(), dimensions=self._build_metric_dimensions(), timestamp=self._build_timestamp())]
metric_array = [MetricDataStatistic(metric_name=self._build_metric_name(), unit=self.vl.type_instance, dimensions=self._build_metric_dimensions(), timestamp=self._build_timestamp())]
if self.config.push_asg:
metric_array.append(MetricDataStatistic(metric_name=self._build_metric_name(), dimensions=self._build_asg_dimension(), timestamp=self._build_timestamp()))
if self.config.push_constant:
Expand Down

0 comments on commit 88222b0

Please sign in to comment.