Class: AWSCDK::CloudWatch::MathExpressionProps

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

Overview

Properties for a MathExpression.

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, expression:, using_metrics: nil) ⇒ MathExpressionProps

Returns a new instance of MathExpressionProps.

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.

  • expression (String)

    The expression defining the metric.

  • using_metrics (Hash{String => AWSCDK::CloudWatch::IMetric}, nil) (defaults to: nil)

    The metrics used in the expression, in a map.



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

def initialize(color: nil, label: nil, period: nil, search_account: nil, search_region: nil, expression:, using_metrics: 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?
  @expression = expression
  Jsii::Type.check_type(@expression, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "expression")
  @using_metrics = using_metrics
  Jsii::Type.check_type(@using_metrics, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jbG91ZHdhdGNoLklNZXRyaWMifSwia2luZCI6Im1hcCJ9fQ==")), "usingMetrics") unless @using_metrics.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/math_expression_props.rb', line 35

def color
  @color
end

#expressionString (readonly)

The expression defining the metric.

When an expression contains a SEARCH function, it cannot be used within an Alarm.

Returns:

  • (String)


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

def expression
  @expression
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/math_expression_props.rb', line 61

def label
  @label
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/math_expression_props.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/math_expression_props.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/math_expression_props.rb', line 85

def search_region
  @search_region
end

#using_metricsHash{String => AWSCDK::CloudWatch::IMetric}? (readonly)

Note:

Default: - Empty map.

The metrics used in the expression, in a map.

The key is the identifier that represents the given metric in the expression, and the value is the actual Metric object.

The period of each metric in using_metrics is ignored and instead overridden by the period specified for the MathExpression construct. Even if no period is specified for the MathExpression, it will be overridden by the default value (Duration.minutes(5)).

Example:

metrics = nil # AWSCDK::ElasticLoadBalancingv2::IApplicationLoadBalancerMetrics

AWSCDK::CloudWatch::MathExpression.new({
    expression: "m1+m2",
    label: "AlbErrors",
    using_metrics: {
        m1: metrics.custom("HTTPCode_ELB_500_Count", {
            period: AWSCDK::Duration.minutes(1),
             # <- This period will be ignored
            statistic: "Sum",
            label: "HTTPCode_ELB_500_Count",
        }),
        m2: metrics.custom("HTTPCode_ELB_502_Count", {
            period: AWSCDK::Duration.minutes(1),
             # <- This period will be ignored
            statistic: "Sum",
            label: "HTTPCode_ELB_502_Count",
        }),
    },
    period: AWSCDK::Duration.minutes(3),
})

Returns:



131
132
133
# File 'cloud_watch/math_expression_props.rb', line 131

def using_metrics
  @using_metrics
end

Class Method Details

.jsii_propertiesObject



133
134
135
136
137
138
139
140
141
142
143
# File 'cloud_watch/math_expression_props.rb', line 133

def self.jsii_properties
  {
    :color => "color",
    :label => "label",
    :period => "period",
    :search_account => "searchAccount",
    :search_region => "searchRegion",
    :expression => "expression",
    :using_metrics => "usingMetrics",
  }
end

Instance Method Details

#to_jsiiObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'cloud_watch/math_expression_props.rb', line 145

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