parent
d8f6f77a0f
commit
81f3cbb548
4 changed files with 62 additions and 9 deletions
|
|
@ -10,6 +10,8 @@ from .utils import make_arn_for_dashboard
|
|||
|
||||
DEFAULT_ACCOUNT_ID = 123456789012
|
||||
|
||||
_EMPTY_LIST = tuple()
|
||||
|
||||
|
||||
class Dimension(object):
|
||||
|
||||
|
|
@ -146,14 +148,14 @@ class Statistics:
|
|||
return sum(self.values)
|
||||
|
||||
@property
|
||||
def min(self):
|
||||
def minimum(self):
|
||||
if 'Minimum' not in self.stats:
|
||||
return None
|
||||
|
||||
return min(self.values)
|
||||
|
||||
@property
|
||||
def max(self):
|
||||
def maximum(self):
|
||||
if 'Maximum' not in self.stats:
|
||||
return None
|
||||
|
||||
|
|
@ -228,7 +230,7 @@ class CloudWatchBackend(BaseBackend):
|
|||
def put_metric_data(self, namespace, metric_data):
|
||||
for metric_member in metric_data:
|
||||
self.metric_data.append(MetricDatum(
|
||||
namespace, metric_member['MetricName'], float(metric_member['Value']), metric_member['Dimensions.member'], metric_member.get('Timestamp')))
|
||||
namespace, metric_member['MetricName'], float(metric_member['Value']), metric_member.get('Dimensions.member', _EMPTY_LIST), metric_member.get('Timestamp')))
|
||||
|
||||
def get_metric_statistics(self, namespace, metric_name, start_time, end_time, period, stats):
|
||||
period_delta = timedelta(seconds=period)
|
||||
|
|
|
|||
|
|
@ -276,27 +276,27 @@ GET_METRIC_STATISTICS_TEMPLATE = """<GetMetricStatisticsResponse xmlns="http://m
|
|||
<Datapoints>
|
||||
{% for datapoint in datapoints %}
|
||||
<Datapoint>
|
||||
{% if datapoint.sum %}
|
||||
{% if datapoint.sum is not none %}
|
||||
<Sum>{{ datapoint.sum }}</Sum>
|
||||
{% endif %}
|
||||
|
||||
{% if datapoint.average %}
|
||||
{% if datapoint.average is not none %}
|
||||
<Average>{{ datapoint.average }}</Average>
|
||||
{% endif %}
|
||||
|
||||
{% if datapoint.maximum %}
|
||||
{% if datapoint.maximum is not none %}
|
||||
<Maximum>{{ datapoint.maximum }}</Maximum>
|
||||
{% endif %}
|
||||
|
||||
{% if datapoint.minimum %}
|
||||
{% if datapoint.minimum is not none %}
|
||||
<Minimum>{{ datapoint.minimum }}</Minimum>
|
||||
{% endif %}
|
||||
|
||||
{% if datapoint.sample_count %}
|
||||
{% if datapoint.sample_count is not none %}
|
||||
<SampleCount>{{ datapoint.sample_count }}</SampleCount>
|
||||
{% endif %}
|
||||
|
||||
{% if datapoint.extended_statistics %}
|
||||
{% if datapoint.extended_statistics is not none %}
|
||||
<ExtendedStatistics>{{ datapoint.extended_statistics }}</ExtendedStatistics>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue