MetricFilterOptions

class aws_cdk.aws_logs.MetricFilterOptions(*, filter_pattern, metric_name, metric_namespace, apply_on_transformed_logs=None, default_value=None, dimensions=None, filter_name=None, metric_value=None, unit=None)

Bases: object

Properties for a MetricFilter created from a LogGroup.

Parameters:
  • filter_pattern (IFilterPattern) – Pattern to search for log events.

  • metric_name (str) – The name of the metric to emit.

  • metric_namespace (str) – The namespace of the metric to emit.

  • apply_on_transformed_logs (Optional[bool]) – 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. Default: - false

  • default_value (Union[int, float, None]) – The value to emit if the pattern does not match a particular event. Default: No metric emitted.

  • dimensions (Optional[Mapping[str, str]]) – The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. Default: - No dimensions attached to metrics.

  • filter_name (Optional[str]) – The name of the metric filter. Default: - Cloudformation generated name.

  • metric_value (Optional[str]) – 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’. Default: “1”

  • unit (Optional[Unit]) – The unit to assign to the metric. Default: - No unit attached to metrics.

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_cloudwatch as cloudwatch
from aws_cdk import aws_logs as logs

# filter_pattern: logs.IFilterPattern

metric_filter_options = logs.MetricFilterOptions(
    filter_pattern=filter_pattern,
    metric_name="metricName",
    metric_namespace="metricNamespace",

    # the properties below are optional
    apply_on_transformed_logs=False,
    default_value=123,
    dimensions={
        "dimensions_key": "dimensions"
    },
    filter_name="filterName",
    metric_value="metricValue",
    unit=cloudwatch.Unit.SECONDS
)

Attributes

apply_on_transformed_logs

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.

Default:
  • false

default_value

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

Default:

No metric emitted.

dimensions

The fields to use as dimensions for the metric.

One metric filter can include as many as three dimensions.

Default:
  • No dimensions attached to metrics.

See:

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

filter_name

The name of the metric filter.

Default:
  • Cloudformation generated name.

filter_pattern

Pattern to search for log events.

metric_name

The name of the metric to emit.

metric_namespace

The namespace of the metric to emit.

metric_value

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’.

Default:

“1”

unit

The unit to assign to the metric.

Default:
  • No unit attached to metrics.

See:

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