Class: AWSCDK::Logs::MetricFilterOptions

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

Overview

Properties for a MetricFilter created from a LogGroup.

Direct Known Subclasses

MetricFilterProps

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter_pattern:, metric_name:, metric_namespace:, apply_on_transformed_logs: nil, default_value: nil, dimensions: nil, filter_name: nil, metric_value: nil, unit: nil) ⇒ MetricFilterOptions

Returns a new instance of MetricFilterOptions.

Parameters:

  • filter_pattern (AWSCDK::Logs::IFilterPattern)

    Pattern to search for log events.

  • metric_name (String)

    The name of the metric to emit.

  • metric_namespace (String)

    The namespace of the metric to emit.

  • apply_on_transformed_logs (Boolean, nil) (defaults to: nil)

    Whether the metric filter is applied on the tranformed logs.

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

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

  • dimensions (Hash{String => String}, nil) (defaults to: nil)

    The fields to use as dimensions for the metric.

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

    The name of the metric filter.

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

    The value to emit for the metric.

  • unit (AWSCDK::CloudWatch::Unit, nil) (defaults to: nil)

    The unit to assign to the metric.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'logs/metric_filter_options.rb', line 16

def initialize(filter_pattern:, metric_name:, metric_namespace:, apply_on_transformed_logs: nil, default_value: nil, dimensions: nil, filter_name: nil, metric_value: nil, unit: nil)
  @filter_pattern = filter_pattern
  Jsii::Type.check_type(@filter_pattern, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbG9ncy5JRmlsdGVyUGF0dGVybiJ9")), "filterPattern")
  @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")
  @apply_on_transformed_logs = apply_on_transformed_logs
  Jsii::Type.check_type(@apply_on_transformed_logs, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "applyOnTransformedLogs") unless @apply_on_transformed_logs.nil?
  @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("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "dimensions") unless @dimensions.nil?
  @filter_name = filter_name
  Jsii::Type.check_type(@filter_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "filterName") unless @filter_name.nil?
  @metric_value = metric_value
  Jsii::Type.check_type(@metric_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricValue") unless @metric_value.nil?
  @unit = unit
  Jsii::Type.check_type(@unit, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5Vbml0In0=")), "unit") unless @unit.nil?
end

Instance Attribute Details

#apply_on_transformed_logsBoolean? (readonly)

Note:

Default: - 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.

Returns:

  • (Boolean, nil)


56
57
58
# File 'logs/metric_filter_options.rb', line 56

def apply_on_transformed_logs
  @apply_on_transformed_logs
end

#default_valueNumeric? (readonly)

Note:

Default: No metric emitted.

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

Returns:

  • (Numeric, nil)


61
62
63
# File 'logs/metric_filter_options.rb', line 61

def default_value
  @default_value
end

#dimensionsHash{String => String}? (readonly)

Note:

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.



69
70
71
# File 'logs/metric_filter_options.rb', line 69

def dimensions
  @dimensions
end

#filter_nameString? (readonly)

Note:

Default: - Cloudformation generated name.

The name of the metric filter.

Returns:

  • (String, nil)


74
75
76
# File 'logs/metric_filter_options.rb', line 74

def filter_name
  @filter_name
end

#filter_patternAWSCDK::Logs::IFilterPattern (readonly)

Pattern to search for log events.



40
41
42
# File 'logs/metric_filter_options.rb', line 40

def filter_pattern
  @filter_pattern
end

#metric_nameString (readonly)

The name of the metric to emit.

Returns:

  • (String)


44
45
46
# File 'logs/metric_filter_options.rb', line 44

def metric_name
  @metric_name
end

#metric_namespaceString (readonly)

The namespace of the metric to emit.

Returns:

  • (String)


48
49
50
# File 'logs/metric_filter_options.rb', line 48

def metric_namespace
  @metric_namespace
end

#metric_valueString? (readonly)

Note:

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

Returns:

  • (String, nil)


89
90
91
# File 'logs/metric_filter_options.rb', line 89

def metric_value
  @metric_value
end

#unitAWSCDK::CloudWatch::Unit? (readonly)

Note:

Default: - No unit attached to metrics.

The unit to assign to the metric.



95
96
97
# File 'logs/metric_filter_options.rb', line 95

def unit
  @unit
end

Class Method Details

.jsii_propertiesObject



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'logs/metric_filter_options.rb', line 97

def self.jsii_properties
  {
    :filter_pattern => "filterPattern",
    :metric_name => "metricName",
    :metric_namespace => "metricNamespace",
    :apply_on_transformed_logs => "applyOnTransformedLogs",
    :default_value => "defaultValue",
    :dimensions => "dimensions",
    :filter_name => "filterName",
    :metric_value => "metricValue",
    :unit => "unit",
  }
end

Instance Method Details

#to_jsiiObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'logs/metric_filter_options.rb', line 111

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