# MetricsConfig

Configuration for collecting metrics from the event source.

- Source: [`aws-lambda/lib/event-source-mapping.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts#L418)
- Type last changed: v2.168.0 · 20 Nov 2024

## Example

```ts
import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';

declare const fn: lambda.Function;
const table = new dynamodb.Table(this, 'Table', {
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
  stream: dynamodb.StreamViewType.NEW_IMAGE,
});

fn.addEventSource(new eventsources.DynamoEventSource(table, {
  startingPosition: lambda.StartingPosition.LATEST,
  metricsConfig: {
    metrics: [lambda.MetricType.EVENT_COUNT],
  }
}));
```

## Properties

- `metrics`: [MetricType](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.MetricType.html)[] (required) — List of metric types to enable for this event source.
