Class: AWSCDK::Logs::CfnMetricFilter::MetricTransformationProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
logs/cfn_metric_filter.rb

Overview

MetricTransformation is a property of the AWS::Logs::MetricFilter resource that describes how to transform log streams into a CloudWatch metric.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric_name:, metric_namespace:, metric_value:, default_value: nil, dimensions: nil, unit: nil) ⇒ MetricTransformationProperty

Returns a new instance of MetricTransformationProperty.

Parameters:

  • metric_name (String)

    The name of the CloudWatch metric.

  • metric_namespace (String)

    A custom namespace to contain your metric in CloudWatch.

  • metric_value (String)

    The value that is published to the CloudWatch metric.

  • default_value (Numeric, nil) (defaults to: nil)

    (Optional) The value to emit when a filter pattern does not match a log event.

  • dimensions (AWSCDK::IResolvable, Array<AWSCDK::IResolvable, AWSCDK::Logs::CfnMetricFilter::DimensionProperty>, nil) (defaults to: nil)

    The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.

  • unit (String, nil) (defaults to: nil)

    The unit to assign to the metric.



636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File 'logs/cfn_metric_filter.rb', line 636

def initialize(metric_name:, metric_namespace:, metric_value:, default_value: nil, dimensions: nil, unit: nil)
  @metric_name = metric_name
  Jsii::Type.check_type(@metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName")
  @metric_namespace = metric_namespace
  Jsii::Type.check_type(@metric_namespace, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricNamespace")
  @metric_value = metric_value
  Jsii::Type.check_type(@metric_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricValue")
  @default_value = default_value
  Jsii::Type.check_type(@default_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "defaultValue") unless @default_value.nil?
  @dimensions = dimensions
  Jsii::Type.check_type(@dimensions, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbG9ncy5DZm5NZXRyaWNGaWx0ZXIuRGltZW5zaW9uUHJvcGVydHkifV19fSwia2luZCI6ImFycmF5In19XX19")), "dimensions") unless @dimensions.nil?
  @unit = unit
  Jsii::Type.check_type(@unit, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "unit") unless @unit.nil?
end

Instance Attribute Details

#default_valueNumeric? (readonly)

(Optional) The value to emit when a filter pattern does not match a log event.

This value can be null.



676
677
678
# File 'logs/cfn_metric_filter.rb', line 676

def default_value
  @default_value
end

#dimensionsAWSCDK::IResolvable, ... (readonly)

The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.

Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as IPAddress or request_id as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric.

CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified dimensions within a certain amount of time. This helps to prevent accidental high charges.

You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see Creating a Billing Alarm to Monitor Your Estimated AWS Charges .



687
688
689
# File 'logs/cfn_metric_filter.rb', line 687

def dimensions
  @dimensions
end

#metric_nameString (readonly)

The name of the CloudWatch metric.



655
656
657
# File 'logs/cfn_metric_filter.rb', line 655

def metric_name
  @metric_name
end

#metric_namespaceString (readonly)

A custom namespace to contain your metric in CloudWatch.

Use namespaces to group together metrics that are similar. For more information, see Namespaces .



662
663
664
# File 'logs/cfn_metric_filter.rb', line 662

def metric_namespace
  @metric_namespace
end

#metric_valueString (readonly)

The value that is published to the CloudWatch metric.

For example, if you're counting the occurrences of a particular term like Error , specify 1 for the metric value. If you're counting the number of bytes transferred, reference the value that is in the log event by using $. followed by the name of the field that you specified in the filter pattern, such as $.size .



669
670
671
# File 'logs/cfn_metric_filter.rb', line 669

def metric_value
  @metric_value
end

#unitString? (readonly)

The unit to assign to the metric.

If you omit this, the unit is set as None .



694
695
696
# File 'logs/cfn_metric_filter.rb', line 694

def unit
  @unit
end

Class Method Details

.jsii_propertiesObject



696
697
698
699
700
701
702
703
704
705
# File 'logs/cfn_metric_filter.rb', line 696

def self.jsii_properties
  {
    :metric_name => "metricName",
    :metric_namespace => "metricNamespace",
    :metric_value => "metricValue",
    :default_value => "defaultValue",
    :dimensions => "dimensions",
    :unit => "unit",
  }
end

Instance Method Details

#to_jsiiObject



707
708
709
710
711
712
713
714
715
716
717
718
# File 'logs/cfn_metric_filter.rb', line 707

def to_jsii
  result = {}
  result.merge!({
    "metricName" => @metric_name,
    "metricNamespace" => @metric_namespace,
    "metricValue" => @metric_value,
    "defaultValue" => @default_value,
    "dimensions" => @dimensions,
    "unit" => @unit,
  })
  result.compact
end