Class: AWSCDK::CloudWatch::MathExpression
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::CloudWatch::MathExpression
- Includes:
- IMetric
- Defined in:
- cloud_watch/math_expression.rb
Overview
A math expression built with metric(s) emitted by a service.
The math expression is a combination of an expression (x+y) and metrics to apply expression on. It also contains metadata which is used only in graphs, such as color and label. It makes sense to embed this in here, so that compound constructs can attach that metadata to metrics they expose.
MathExpression can also be used for search expressions. In this case, it also optionally accepts a searchRegion and searchAccount property for cross-environment search expressions.
This class does not represent a resource, so hence is not a construct. Instead, MathExpression is an abstraction that makes it easy to specify metrics for use in both alarms and graphs.
Class Method Summary collapse
Instance Method Summary collapse
-
#color ⇒ String?
The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph.
-
#create_alarm(scope, id, props) ⇒ AWSCDK::CloudWatch::Alarm
Make a new Alarm for this metric.
-
#expression ⇒ String
The expression defining the metric.
-
#initialize(props) ⇒ MathExpression
constructor
A new instance of MathExpression.
-
#label ⇒ String?
Label for this metric when added to a Graph.
-
#period ⇒ AWSCDK::Duration
Aggregation period of this metric.
-
#search_account ⇒ String?
Account to evaluate search expressions within.
-
#search_region ⇒ String?
Region to evaluate search expressions within.
-
#to_metric_config ⇒ AWSCDK::CloudWatch::MetricConfig
Inspect the details of the metric object.
-
#to_string ⇒ String
Returns a string representation of an object.
-
#using_metrics ⇒ Hash{String => AWSCDK::CloudWatch::IMetric}
The metrics used in the expression as KeyValuePair
. -
#warnings ⇒ Array<String>?
deprecated
Deprecated.
- use warningsV2
-
#warnings_v2 ⇒ Hash{String => String}?
Warnings generated by this math expression.
-
#with(props) ⇒ AWSCDK::CloudWatch::MathExpression
Return a copy of Metric with properties changed.
Constructor Details
#initialize(props) ⇒ MathExpression
Returns a new instance of MathExpression.
23 24 25 26 27 |
# File 'cloud_watch/math_expression.rb', line 23 def initialize(props) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MathExpressionProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NYXRoRXhwcmVzc2lvblByb3BzIn0=")), "props") Jsii::Object.instance_method(:initialize).bind(self).call(props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'cloud_watch/math_expression.rb', line 29 def self.jsii_overridable_methods { :expression => { kind: :property, name: "expression", is_optional: false }, :period => { kind: :property, name: "period", is_optional: false }, :using_metrics => { kind: :property, name: "usingMetrics", is_optional: false }, :color => { kind: :property, name: "color", is_optional: true }, :label => { kind: :property, name: "label", is_optional: true }, :search_account => { kind: :property, name: "searchAccount", is_optional: true }, :search_region => { kind: :property, name: "searchRegion", is_optional: true }, :warnings => { kind: :property, name: "warnings", is_optional: true }, :warnings_v2 => { kind: :property, name: "warningsV2", is_optional: true }, :create_alarm => { kind: :method, name: "createAlarm", is_optional: false }, :to_metric_config => { kind: :method, name: "toMetricConfig", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :with => { kind: :method, name: "with", is_optional: false }, } end |
Instance Method Details
#color ⇒ String?
The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.
71 72 73 |
# File 'cloud_watch/math_expression.rb', line 71 def color() jsii_get_property("color") end |
#create_alarm(scope, id, props) ⇒ AWSCDK::CloudWatch::Alarm
Make a new Alarm for this metric.
Combines both properties that may adjust the metric (aggregation) as well as alarm properties.
120 121 122 123 124 125 126 |
# File 'cloud_watch/math_expression.rb', line 120 def create_alarm(scope, id, props) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::CreateAlarmOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5DcmVhdGVBbGFybU9wdGlvbnMifQ==")), "props") jsii_call_method("createAlarm", [scope, id, props]) end |
#expression ⇒ String
The expression defining the metric.
50 51 52 |
# File 'cloud_watch/math_expression.rb', line 50 def expression() jsii_get_property("expression") end |
#label ⇒ String?
Label for this metric when added to a Graph.
78 79 80 |
# File 'cloud_watch/math_expression.rb', line 78 def label() jsii_get_property("label") end |
#period ⇒ AWSCDK::Duration
Aggregation period of this metric.
57 58 59 |
# File 'cloud_watch/math_expression.rb', line 57 def period() jsii_get_property("period") end |
#search_account ⇒ String?
Account to evaluate search expressions within.
85 86 87 |
# File 'cloud_watch/math_expression.rb', line 85 def search_account() jsii_get_property("searchAccount") end |
#search_region ⇒ String?
Region to evaluate search expressions within.
92 93 94 |
# File 'cloud_watch/math_expression.rb', line 92 def search_region() jsii_get_property("searchRegion") end |
#to_metric_config ⇒ AWSCDK::CloudWatch::MetricConfig
Inspect the details of the metric object.
131 132 133 |
# File 'cloud_watch/math_expression.rb', line 131 def to_metric_config() jsii_call_method("toMetricConfig", []) end |
#to_string ⇒ String
Returns a string representation of an object.
138 139 140 |
# File 'cloud_watch/math_expression.rb', line 138 def to_string() jsii_call_method("toString", []) end |
#using_metrics ⇒ Hash{String => AWSCDK::CloudWatch::IMetric}
The metrics used in the expression as KeyValuePair
64 65 66 |
# File 'cloud_watch/math_expression.rb', line 64 def using_metrics() jsii_get_property("usingMetrics") end |
#warnings ⇒ Array<String>?
- use warningsV2
Warnings generated by this math expression.
100 101 102 |
# File 'cloud_watch/math_expression.rb', line 100 def warnings() jsii_get_property("warnings") end |
#warnings_v2 ⇒ Hash{String => String}?
Warnings generated by this math expression.
107 108 109 |
# File 'cloud_watch/math_expression.rb', line 107 def warnings_v2() jsii_get_property("warningsV2") end |
#with(props) ⇒ AWSCDK::CloudWatch::MathExpression
Return a copy of Metric with properties changed.
All properties except namespace and metricName can be changed.
148 149 150 151 152 |
# File 'cloud_watch/math_expression.rb', line 148 def with(props) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MathExpressionOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NYXRoRXhwcmVzc2lvbk9wdGlvbnMifQ==")), "props") jsii_call_method("with", [props]) end |