Skip to content
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

chore(elasticloadbalancingv2): specific 5XX CloudWatch metrics for ALB #30659

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,26 @@ export enum HttpCodeElb {
* The number of HTTP 5XX server error codes that originate from the load balancer.
*/
ELB_5XX_COUNT = 'HTTPCode_ELB_5XX_Count',

/**
* The number of HTTP 500 server error codes that originate from the load balancer.
*/
ELB_500_COUNT = 'HTTPCode_ELB_500_Count',

/**
* The number of HTTP 502 server error codes that originate from the load balancer.
*/
ELB_502_COUNT = 'HTTPCode_ELB_502_Count',

/**
* The number of HTTP 503 server error codes that originate from the load balancer.
*/
ELB_503_COUNT = 'HTTPCode_ELB_503_Count',

/**
* The number of HTTP 504 server error codes that originate from the load balancer.
*/
ELB_504_COUNT = 'HTTPCode_ELB_504_Count',
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,29 @@ describe('tests', () => {
}
});

test.each([
elbv2.HttpCodeElb.ELB_500_COUNT,
elbv2.HttpCodeElb.ELB_502_COUNT,
elbv2.HttpCodeElb.ELB_503_COUNT,
elbv2.HttpCodeElb.ELB_504_COUNT,
])('use specific load balancer generated 5XX metrics', (metricName) => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc });

// WHEN
const metric = lb.metrics.httpCodeElb(metricName);

// THEN
expect(metric.namespace).toEqual('AWS/ApplicationELB');
expect(metric.statistic).toEqual('Sum');
expect(metric.metricName).toEqual(metricName);
expect(stack.resolve(metric.dimensions)).toEqual({
LoadBalancer: { 'Fn::GetAtt': ['LB8A12904C', 'LoadBalancerFullName'] },
});
});

test('loadBalancerName', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down