-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
(elbv2): metrics.(httpCodeElb|httpCodeTarget) doesn't work with GraphWidget #31066
Comments
Issue not reproducible using code below, without using ECS patterns (used import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as cdk from 'aws-cdk-lib';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
export class CdktestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const cloudwatchDashboard = new cloudwatch.Dashboard(this, 'myDashboard', {
dashboardName: 'MyCloudWatchDashboard'
});
const defaultVpc = ec2.Vpc.fromLookup(this, 'MyDefaultVpc', {
isDefault: true
});
const loadBalancer = new elbv2.ApplicationLoadBalancer(this, 'MyALB', {
vpc: defaultVpc
});
const listener = loadBalancer.addListener('Listener', { port: 80 });
const targetGroup = listener.addTargets('Fleet', { port: 80 });
const alb5xxCountMetric = loadBalancer.metrics.httpCodeElb(elbv2.HttpCodeElb.ELB_5XX_COUNT);
const targetGroup5xxCountMetric = targetGroup.metrics.httpCodeTarget(elbv2.HttpCodeTarget.TARGET_5XX_COUNT);
cloudwatchDashboard.addWidgets(
new cloudwatch.GraphWidget({
left: [alb5xxCountMetric],
width: 6,
title: "LB 5xx Response Count",
leftYAxis: {
min: 0,
}
}),
new cloudwatch.GraphWidget({
left: [targetGroup5xxCountMetric],
width: 6,
title: "Target Group 5xx Response Count",
leftYAxis: {
min: 0,
}
})
);
}
} The CloudFormation deployment is successful:
|
Issue not reproducible using ECS patterns as well (used import * as cdk from 'aws-cdk-lib';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns';
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
export class EcsPatternsAlbGraphWidgetStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const loadBalancedService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'MyAlbLoadBalancedfargateService', {
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample')
}
});
const cloudwatchDashboard = new cloudwatch.Dashboard(this, 'myDashboard', {
dashboardName: 'MyCloudWatchDashboard'
});
const alb5xxCountMetric = loadBalancedService.loadBalancer.metrics.httpCodeElb(elbv2.HttpCodeElb.ELB_5XX_COUNT);
const targetGroup5xxCountMetric = loadBalancedService.targetGroup.metrics.httpCodeTarget(elbv2.HttpCodeTarget.TARGET_5XX_COUNT);
cloudwatchDashboard.addWidgets(
new cloudwatch.GraphWidget({
left: [alb5xxCountMetric],
width: 6,
title: "LB 5xx Response Count",
leftYAxis: {
min: 0,
}
}),
new cloudwatch.GraphWidget({
left: [targetGroup5xxCountMetric],
width: 6,
title: "Target Group 5xx Response Count",
leftYAxis: {
min: 0,
}
})
);
}
} CDK deployment works fine and CloudWatch Dashboard is created:
@modosc Somehow, the issue is not reproducible. I noticed that you are using the wrong enum values for Thanks, |
@ashishdhingra this is indeed the issue. importing the correct enums resolves this. i apologize for the noise, thank you for your help. |
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
when i deploy a dashboard with this code:
i get the following errors:
Expected Behavior
this should work out of the box like these (similar) api calls:
Current Behavior
Reproduction Steps
i'm unsure how concisely i can reproduce this, and the failure happens at deploy time, not compile time.
loadBalancedService
is anApplicationLoadBalancedFargateService
so the minimal reproducible steps would be:Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.136.0 (build 94fd33b)
Framework Version
No response
Node.js Version
v18.18.2
OS
Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6020 arm64
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: