Skip to content

Commit e351e81

Browse files
committed
fix(logs): correct metricIncomingLogEvents metric name from IncomingLogs to IncomingLogEvents
The metricIncomingLogEvents() method was using 'IncomingLogs' as the metric name, but the correct CloudWatch metric name per AWS documentation is 'IncomingLogEvents'. This caused alarms created with this method to have no datapoints. Closes #36815
1 parent 69cf4c9 commit e351e81

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/aws-cdk-lib/aws-logs/lib/log-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ abstract class LogGroupBase extends Resource implements ILogGroup {
343343
* ```
344344
*/
345345
public metricIncomingLogEvents(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
346-
return this.metric('IncomingLogs', props);
346+
return this.metric('IncomingLogEvents', props);
347347
}
348348

349349
/**

packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,26 @@ describe('log group', () => {
339339
expect(metric.metricName).toEqual('Field');
340340
});
341341

342+
test('metricIncomingLogEvents uses correct metric name', () => {
343+
const stack = new Stack();
344+
const lg = new LogGroup(stack, 'LogGroup');
345+
346+
const metric = lg.metricIncomingLogEvents();
347+
348+
expect(metric.metricName).toEqual('IncomingLogEvents');
349+
expect(metric.namespace).toEqual('AWS/Logs');
350+
});
351+
352+
test('metricIncomingBytes uses correct metric name', () => {
353+
const stack = new Stack();
354+
const lg = new LogGroup(stack, 'LogGroup');
355+
356+
const metric = lg.metricIncomingBytes();
357+
358+
expect(metric.metricName).toEqual('IncomingBytes');
359+
expect(metric.namespace).toEqual('AWS/Logs');
360+
});
361+
342362
test('extractMetric allows passing in namespaces with "/"', () => {
343363
// GIVEN
344364
const stack = new Stack();

0 commit comments

Comments
 (0)