# MetricFilterOptions

Properties for a MetricFilter created from a LogGroup.

- Source: [`aws-logs/lib/log-group.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-logs/lib/log-group.ts#L813)
- Type last changed: v2.220.0 · 14 Oct 2025

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
import { aws_logs as logs } from 'aws-cdk-lib';

declare const filterPattern: logs.IFilterPattern;
const metricFilterOptions: logs.MetricFilterOptions = {
  filterPattern: filterPattern,
  metricName: 'metricName',
  metricNamespace: 'metricNamespace',

  // the properties below are optional
  applyOnTransformedLogs: false,
  defaultValue: 123,
  dimensions: {
    dimensionsKey: 'dimensions',
  },
  filterName: 'filterName',
  metricValue: 'metricValue',
  unit: cloudwatch.Unit.SECONDS,
};
```

## Properties

- `applyOnTransformedLogs`: boolean = false — Whether the metric filter is applied on the tranformed logs.

  This parameter is valid only for log groups that have an active log transformer.
  If this value is true, the metric filter is applied on the transformed version of the log events instead of the original ingested log events.

- `defaultValue`: number — The value to emit if the pattern does not match a particular event.

  **Default:** No metric emitted.

- `dimensions`: { [key: string]: string } — The fields to use as dimensions for the metric.

  **Default:** No dimensions attached to metrics.

  One metric filter can include as many as three dimensions.

- `filterName`: string — The name of the metric filter.

  **Default:** Cloudformation generated name.

- `filterPattern`: [IFilterPattern](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.IFilterPattern.html) (required) — Pattern to search for log events.

- `metricName`: string (required) — The name of the metric to emit.

- `metricNamespace`: string (required) — The namespace of the metric to emit.

- `metricValue`: string = "1" — The value to emit for the metric.

  Can either be a literal number (typically "1"), or the name of a field in the structure
  to take the value from the matched event. If you are using a field value, the field
  value must have been matched using the pattern.

  If you want to specify a field from a matched JSON structure, use '$.fieldName',
  and make sure the field is in the pattern (if only as '$.fieldName = *').

  If you want to specify a field from a matched space-delimited structure,
  use '$fieldName'.

- `unit`: [Unit](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Unit.html) — The unit to assign to the metric.

  **Default:** No unit attached to metrics.
