-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[aws-cloudwatch] Support region and account in MathExpression #9039
Comments
Is there a reason why when generating the metrics graph JSON the check this seems to be breaking xaxr stacks e.g.,
|
I would have expected Otherwise I don't really see how:
Will fail to locate the metric when deployed into |
Hi, is this still being worked on? |
I created a wrapper class as a workaround for my use case (using CDK version import * as cloudwatch from 'monocdk/aws-cloudwatch';
export interface XaxrMathExpressionProps extends cloudwatch.MathExpressionProps {
/**
* (experimental) Account which this metric comes from.
*
* @default - Deployment account.
* @experimental
*/
readonly account?: string;
/**
* (experimental) Region which this metric comes from.
*
* @default - Deployment region.
* @experimental
*/
readonly region?: string;
}
export class XaxrMathExpression implements cloudwatch.IMetric {
private mathExpression: cloudwatch.MathExpression;
constructor(private readonly props: XaxrMathExpressionProps) {
this.mathExpression = new cloudwatch.MathExpression(props);
}
toAlarmConfig(): cdk.aws_cloudwatch.MetricAlarmConfig {
throw new Error('Method not implemented.');
}
toGraphConfig(): cdk.aws_cloudwatch.MetricGraphConfig {
throw new Error('Method not implemented.');
}
public with(options: cloudwatch.MathExpressionOptions): cloudwatch.IMetric {
return new XaxrMathExpression({
...this.props,
...options
});
}
public toMetricConfig(): cloudwatch.MetricConfig {
const defaultMetricConfig = this.mathExpression.toMetricConfig();
return {
...defaultMetricConfig,
renderingProperties: {
...defaultMetricConfig.renderingProperties,
accountId: this.props.account,
region: this.props.region
}
}
}
} |
…ironment math expressions (aws#9039) Fixes: aws#9039 Currently CDK gives no way to specify account or region on MathExpressions which means it is not possible to run SEARCH or SERVICE_QUOTA expressions against environments other than the deployment environment. The CloudWatch console currently has this capability, however the documentation still states that accountId or region should only be used on metric widgets: https://docs.aws.amazon.com/en_us/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-Metric-Widget-Object . I've left feedback to ask whether this documentation is out of date. This change adds in these properties which can be optionally specified for Dashboards. For the Alarm use case, this change will throw an error if an account or region is provided and it does not match the deployment account/region.
Fixes #9039 (also some prior discussion on #9034) Currently CDK gives no way to specify account or region on MathExpressions which means it is not possible to run search expressions against environments other than the deployment environment. The CloudWatch console currently has this capability, however [the documentation](https://docs.aws.amazon.com/en_us/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-Metric-Widget-Object) still states that `accountId` or `region` should only be used on metric widgets. I've left feedback to ask whether this documentation is out of date or whether it is an undocumented feature. This change adds in the `searchAccount` and `searchRegion` property which can be optionally specified for the Dashboards use case. When a MathExpression with a searchAccount or searchRegion set is attempted to be used within an Alarm, the change throws an error as Alarms do not support search expressions. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…6539) Fixes aws#9039 (also some prior discussion on aws#9034) Currently CDK gives no way to specify account or region on MathExpressions which means it is not possible to run search expressions against environments other than the deployment environment. The CloudWatch console currently has this capability, however [the documentation](https://docs.aws.amazon.com/en_us/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-Metric-Widget-Object) still states that `accountId` or `region` should only be used on metric widgets. I've left feedback to ask whether this documentation is out of date or whether it is an undocumented feature. This change adds in the `searchAccount` and `searchRegion` property which can be optionally specified for the Dashboards use case. When a MathExpression with a searchAccount or searchRegion set is attempted to be used within an Alarm, the change throws an error as Alarms do not support search expressions. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
When trying to specify a cross region/cross account math expression the MathExpression requires also reference to the region and account.
Use Case
Creating cross account and cross region math expressions.
Proposed Solution
The Metric class already supports specifying region and accountId but the MathExpression metric doesnt, we could simply just add it
Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: