Class: AWSCDK::CloudWatch::AnomalyDetectionMetricOptions

Inherits:
MathExpressionOptions
  • Object
show all
Defined in:
cloud_watch/anomaly_detection_metric_options.rb

Overview

Properties needed to make an anomaly detection alarm from a metric.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color: nil, label: nil, period: nil, search_account: nil, search_region: nil, metric:, std_devs: nil) ⇒ AnomalyDetectionMetricOptions

Returns a new instance of AnomalyDetectionMetricOptions.

Parameters:

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

    Color for this metric when added to a Graph in a Dashboard.

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

    Label for this expression when added to a Graph in a Dashboard.

  • period (AWSCDK::Duration, nil) (defaults to: nil)

    The period over which the math expression's statistics are applied.

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

    Account to evaluate search expressions within.

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

    Region to evaluate search expressions within.

  • metric (AWSCDK::CloudWatch::IMetric)

    The metric to add the alarm on.

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

    The number of standard deviations to use for the anomaly detection band.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 14

def initialize(color: nil, label: nil, period: nil, search_account: nil, search_region: nil, metric:, std_devs: nil)
  @color = color
  Jsii::Type.check_type(@color, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "color") unless @color.nil?
  @label = label
  Jsii::Type.check_type(@label, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "label") unless @label.nil?
  @period = period
  Jsii::Type.check_type(@period, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "period") unless @period.nil?
  @search_account = 
  Jsii::Type.check_type(@search_account, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "searchAccount") unless @search_account.nil?
  @search_region = search_region
  Jsii::Type.check_type(@search_region, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "searchRegion") unless @search_region.nil?
  @metric = metric
  Jsii::Type.check_type(@metric, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5JTWV0cmljIn0=")), "metric")
  @std_devs = std_devs
  Jsii::Type.check_type(@std_devs, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "stdDevs") unless @std_devs.nil?
end

Instance Attribute Details

#colorString? (readonly)

Note:

Default: - Automatic color

Color for this metric when added to a Graph in a Dashboard.

Returns:

  • (String, nil)


35
36
37
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 35

def color
  @color
end

#labelString? (readonly)

Note:

Default: - Expression value is used as label

Label for this expression when added to a Graph in a Dashboard.

If this expression evaluates to more than one time series (for example, through the use of METRICS() or SEARCH() expressions), each time series will appear in the graph using a combination of the expression label and the individual metric label. Specify the empty string ('') to suppress the expression label and only keep the metric label.

You can use dynamic labels to show summary information about the displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend. If the math expression produces more than one time series, the maximum will be shown for each individual time series produce by this math expression.

Returns:

  • (String, nil)


61
62
63
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 61

def label
  @label
end

#metricAWSCDK::CloudWatch::IMetric (readonly)

The metric to add the alarm on.

Metric objects can be obtained from most resources, or you can construct custom Metric objects by instantiating one.



92
93
94
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 92

def metric
  @metric
end

#periodAWSCDK::Duration? (readonly)

Note:

Default: Duration.minutes(5)

The period over which the math expression's statistics are applied.

This period overrides all periods in the metrics used in this math expression.

Returns:



69
70
71
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 69

def period
  @period
end

#search_accountString? (readonly)

Note:

Default: - Deployment account.

Account to evaluate search expressions within.

Specifying a searchAccount has no effect to the account used for metrics within the expression (passed via usingMetrics).

Returns:

  • (String, nil)


77
78
79
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 77

def 
  @search_account
end

#search_regionString? (readonly)

Note:

Default: - Deployment region.

Region to evaluate search expressions within.

Specifying a searchRegion has no effect to the region used for metrics within the expression (passed via usingMetrics).

Returns:

  • (String, nil)


85
86
87
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 85

def search_region
  @search_region
end

#std_devsNumeric? (readonly)

Note:

Default: 2

The number of standard deviations to use for the anomaly detection band.

The higher the value, the wider the band.

  • Must be greater than 0. A value of 0 or negative values would not make sense in the context of calculating standard deviations.
  • There is no strict maximum value defined, as standard deviations can theoretically extend infinitely. However, in practice, values beyond 5 or 6 standard deviations are rarely used, as they would result in an extremely wide anomaly detection band, potentially missing significant anomalies.

Returns:

  • (Numeric, nil)


102
103
104
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 102

def std_devs
  @std_devs
end

Class Method Details

.jsii_propertiesObject



104
105
106
107
108
109
110
111
112
113
114
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 104

def self.jsii_properties
  {
    :color => "color",
    :label => "label",
    :period => "period",
    :search_account => "searchAccount",
    :search_region => "searchRegion",
    :metric => "metric",
    :std_devs => "stdDevs",
  }
end

Instance Method Details

#to_jsiiObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'cloud_watch/anomaly_detection_metric_options.rb', line 116

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "color" => @color,
    "label" => @label,
    "period" => @period,
    "searchAccount" => @search_account,
    "searchRegion" => @search_region,
    "metric" => @metric,
    "stdDevs" => @std_devs,
  })
  result.compact
end