def consumer_sqs_delete_duration(request): cw = CloudWatch() return cw.get_metric( util.get_cloudwatch_namespace(os.environ[c.ENV_DEPLOYMENT_STACK_ARN]), c.CW_METRIC_NAME_PROCESSED, c.CW_METRIC_DIMENSION_NAME_CONSUMER, c.CW_METRIC_DIMENSION_DEL, "Average", start=(datetime.datetime.today() - datetime.timedelta(hours=8)))
def cloudwatch_metric(request, namespace, metric_name, dimension_name, dimension_value, aggregation_type, time_delta_hours=8, period_in_seconds=300): if dimension_value not in os.environ: raise ClientError( "The dimension value '{}' is not one of the environment variables. It should be the logical name of a resource. Example: FIFOConsumer." .format(dimension_value)) cw = CloudWatch() return cw.get_metric("AWS/" + namespace, metric_name, dimension_name, os.environ[dimension_value], aggregation_type, start=(datetime.datetime.today() - datetime.timedelta(hours=time_delta_hours)), period=period_in_seconds)