Interface MetricFilterOptions

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Subinterfaces:
MetricFilterProps
All Known Implementing Classes:
MetricFilterOptions.Jsii$Proxy, MetricFilterProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.133.0 (build 0f43e37)", date="2026-06-11T16:21:45.188Z") @Stability(Stable) public interface MetricFilterOptions extends software.amazon.jsii.JsiiSerializable
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 software.amazon.awscdk.services.cloudwatch.*;
 import software.amazon.awscdk.services.logs.*;
 IFilterPattern filterPattern;
 MetricFilterOptions metricFilterOptions = MetricFilterOptions.builder()
         .filterPattern(filterPattern)
         .metricName("metricName")
         .metricNamespace("metricNamespace")
         // the properties below are optional
         .applyOnTransformedLogs(false)
         .defaultValue(123)
         .dimensions(Map.of(
                 "dimensionsKey", "dimensions"))
         .filterName("filterName")
         .metricValue("metricValue")
         .unit(Unit.SECONDS)
         .build();
 
  • Method Details

    • getFilterPattern

      @Stability(Stable) @NotNull IFilterPattern getFilterPattern()
      Pattern to search for log events.
    • getMetricName

      @Stability(Stable) @NotNull String getMetricName()
      The name of the metric to emit.
    • getMetricNamespace

      @Stability(Stable) @NotNull String getMetricNamespace()
      The namespace of the metric to emit.
    • getApplyOnTransformedLogs

      @Stability(Stable) @Nullable default Boolean getApplyOnTransformedLogs()
      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

    • getDefaultValue

      @Stability(Stable) @Nullable default Number getDefaultValue()
      The value to emit if the pattern does not match a particular event.

      Default: No metric emitted.

    • getDimensions

      @Stability(Stable) @Nullable default Map<String,String> getDimensions()
      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 Also:
    • getFilterName

      @Stability(Stable) @Nullable default String getFilterName()
      The name of the metric filter.

      Default: - Cloudformation generated name.

    • getMetricValue

      @Stability(Stable) @Nullable default String getMetricValue()
      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"

    • getUnit

      @Stability(Stable) @Nullable default Unit getUnit()
      The unit to assign to the metric.

      Default: - No unit attached to metrics.

      See Also:
    • builder

      @Stability(Stable) static MetricFilterOptions.Builder builder()
      Returns:
      a MetricFilterOptions.Builder of MetricFilterOptions