aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.92k forks source link

aws-ecs: Metrics in imported FargateService #28590

Open btd opened 10 months ago

btd commented 10 months ago

Describe the bug

Currently there are 3 ways to import Fargate Service:

// from FargateService
fromFargateServiceArn(scope: Construct, id: string, fargateServiceArn: string): IFargateService;
fromFargateServiceAttributes(scope: Construct, id: string, attrs: FargateServiceAttributes): IBaseService;
// from BaseService
fromServiceArnWithCluster(scope: Construct, id: string, serviceArn: string): IBaseService;

You can see that output it is either IBaseService or IFargateService

To get metrics as they currently defined i need to get BaseService:

metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
metricMemoryUtilization(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
metricCpuUtilization(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

For example INetworkLoadBalancer contains separate metrics property and i can easily use imported instance.

Expected Behavior

Access to metrics provided via IBaseService or IFargateService

Current Behavior

No access and no clear workaround.

Reproduction Steps

See description please

Possible Solution

Similar to INetworkLoadBalancer we can expose metrics property with defined metrics

Additional Information/Context

No response

CDK CLI Version

2.115.0 (build 58027ee)

Framework Version

No response

Node.js Version

18.x

OS

AL2

Language

TypeScript

Language Version

~5.3

Other information

No response

pahud commented 10 months ago

Sounds good and this seems a feature request to me. Please help us prioritize with 👍 . Thank you.