aws-cdk-lib.aws_logs.MetricFilterOptions

interface MetricFilterOptions

LanguageType name
.NETAmazon.CDK.AWS.Logs.MetricFilterOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslogs#MetricFilterOptions
Javasoftware.amazon.awscdk.services.logs.MetricFilterOptions
Pythonaws_cdk.aws_logs.MetricFilterOptions
TypeScript (source)aws-cdk-lib » aws_logs » MetricFilterOptions

Properties for a MetricFilter created from a LogGroup.

Example

// 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
  defaultValue: 123,
  dimensions: {
    dimensionsKey: 'dimensions',
  },
  filterName: 'filterName',
  metricValue: 'metricValue',
  unit: cloudwatch.Unit.SECONDS,
};

Properties

NameTypeDescription
filterPatternIFilterPatternPattern to search for log events.
metricNamestringThe name of the metric to emit.
metricNamespacestringThe namespace of the metric to emit.
defaultValue?numberThe value to emit if the pattern does not match a particular event.
dimensions?{ [string]: string }The fields to use as dimensions for the metric.
filterName?stringThe name of the metric filter.
metricValue?stringThe value to emit for the metric.
unit?UnitThe unit to assign to the metric.

filterPattern

Type: IFilterPattern

Pattern to search for log events.


metricName

Type: string

The name of the metric to emit.


metricNamespace

Type: string

The namespace of the metric to emit.


defaultValue?

Type: number (optional, default: No metric emitted.)

The value to emit if the pattern does not match a particular event.


dimensions?

Type: { [string]: string } (optional, default: No dimensions attached to metrics.)

The fields to use as dimensions for the metric.

One metric filter can include as many as three dimensions.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-logs-metricfilter-metrictransformation.html#cfn-logs-metricfilter-metrictransformation-dimensions


filterName?

Type: string (optional, default: Cloudformation generated name.)

The name of the metric filter.


metricValue?

Type: string (optional, default: "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?

Type: Unit (optional, default: No unit attached to metrics.)

The unit to assign to the metric.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-logs-metricfilter-metrictransformation.html#cfn-logs-metricfilter-metrictransformation-unit