diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts index c97463a218cbd..bea4a50407e5a 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts @@ -312,13 +312,7 @@ function metricJson(metric: IMetric, yAxis: string): any[] { } // Options - ret.push({ - yAxis, - label: config.label, - color: config.color, - period: config.period, - stat: config.statistic, - }); + ret.push({ yAxis, ...config.renderingProperties }); return ret; } diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/metric-types.ts b/packages/@aws-cdk/aws-cloudwatch/lib/metric-types.ts index 5a3d90895ecfe..1c4aad10029d3 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/metric-types.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/metric-types.ts @@ -132,6 +132,16 @@ export interface MetricGraphConfig { */ readonly metricName: string; + /** + * Rendering properties override yAxis parameter of the widget object + */ + readonly renderingProperties: MetricRenderingProperties; +} + +/** + * Custom rendering properties that override the default rendering properties specified in the yAxis parameter of the widget object. + */ +export interface MetricRenderingProperties { /** * How many seconds to aggregate over */ @@ -150,10 +160,5 @@ export interface MetricGraphConfig { /** * Aggregation function to use (can be either simple or a percentile) */ - readonly statistic?: string; - - /** - * The unit of the alarm - */ - readonly unit?: Unit; -} \ No newline at end of file + readonly stat?: string; +} diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts index a5dbfaeb371e3..db5b2068c5eed 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts @@ -195,11 +195,12 @@ export class Metric implements IMetric { dimensions: this.dimensionsAsList(), namespace: this.namespace, metricName: this.metricName, - period: this.period.toSeconds(), - statistic: this.statistic, - unit: this.unit, - color: this.color, - label: this.label, + renderingProperties: { + period: this.period.toSeconds(), + stat: this.statistic, + color: this.color, + label: this.label, + }, }; } diff --git a/packages/@aws-cdk/aws-cloudwatch/package.json b/packages/@aws-cdk/aws-cloudwatch/package.json index 3e3159d63d038..3dfd578500bec 100644 --- a/packages/@aws-cdk/aws-cloudwatch/package.json +++ b/packages/@aws-cdk/aws-cloudwatch/package.json @@ -81,7 +81,7 @@ "awslint": { "exclude": [ "duration-prop-type:@aws-cdk/aws-cloudwatch.MetricAlarmConfig.period", - "duration-prop-type:@aws-cdk/aws-cloudwatch.MetricGraphConfig.period" + "duration-prop-type:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.period" ] }, "engines": {