(aws-lambda): IAlias "metrics" function returns metrics for function instead of alias
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### What is the problem?
IAlias "metrics" function returns metrics for function instead of alias.
### Reproduction Steps
```
const alias = Alias.fromAliasAttributes(this, lambdaName, {
aliasName: 'live',
aliasVersion: Version.fromVersionArn(this, `${lambdaName}version`,`${lambdaArn}:1`),
});
alias.metricInvocations();
```
### What did you expect to happen?
The metric returned should be for the alias.
Source on dashboard should look like this:
```
[ "AWS/Lambda", "Invocations", "FunctionName", "MyLambda", "Resource", "MyLambda:live", { "accountId": "281910761090", "region": "ap-southeast-2", "stat": "Sum", "visible": false, "id": "countSYD" } ],
```
### What actually happened?
The metric returned was for the lambda instead of the alias
[ "AWS/Lambda", "Invocations", "FunctionName", "MyLambda", { "accountId": "281910761090", "region": "ap-southeast-2", "stat": "Sum", "visible": false, "id": "countSYD" } ],
### CDK CLI Version
1.143.0
### Framework Version
1.139.0
### Node.js Version
16
### OS
Mac OS
### Language
Typescript
### Language Version
3.6.4
### Other information
The issue could be fixed by adding the correct metric function here: https://github.com/aws/aws-cdk/blob/v1.144.0/packages/@aws-cdk/aws-lambda/lib/alias.ts#L92
Or by adding the correct metric function here: https://github.com/aws/aws-cdk/blob/v1.144.0/packages/%40aws-cdk/aws-lambda/lib/function-base.ts#L489
Contributor guide
Research direction
Start by reading packages/@aws-cdk/aws-lambda/lib/alias.ts around the linked metric function and compare it with packages/@aws-cdk/aws-lambda/lib/function-base.ts. Reproduce alias.metricInvocations() with the provided example and inspect the generated dashboard metric. Done means the metric includes the alias Resource dimension rather than only the function dimensions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100