Class: AWSCDK::CloudWatch::SearchExpression
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::CloudWatch::SearchExpression
- Includes:
- IMetric
- Defined in:
- cloud_watch/search_expression.rb
Overview
A CloudWatch search expression for dynamically finding and graphing multiple related metrics.
Search expressions allow you to search for and graph multiple related metrics from a single expression. This is particularly useful in dynamic environments where the exact metric names or dimensions may not be known at deployment time.
Example:
search_expression = AWSCDK::CloudWatch::SearchExpression.new({
expression: "SEARCH('{AWS/EC2,InstanceId} CPUUtilization', 'Average', 300)",
label: "EC2 CPU Utilization",
period: AWSCDK::Duration.minutes(5),
})
This class does not represent a resource, so hence is not a construct. Instead, SearchExpression is an abstraction that makes it easy to specify metrics for use in graphs.
Class Method Summary collapse
Instance Method Summary collapse
-
#color ⇒ String?
Hex color code (e.g. '#00ff00'), to use when rendering the resulting metrics in a graph.
-
#expression ⇒ String
The search expression defining the metrics to be retrieved.
-
#initialize(props) ⇒ SearchExpression
constructor
A new instance of SearchExpression.
-
#label ⇒ String?
The label is used as a prefix for the title of each metric returned by the search expression.
-
#period ⇒ AWSCDK::Duration
The aggregation period for the metrics produced by the Search Expression.
-
#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.
-
#warnings ⇒ Array<String>?
deprecated
Deprecated.
- use warningsV2
-
#warnings_v2 ⇒ Hash{String => String}?
Warnings generated by this search expression.
-
#with(props) ⇒ AWSCDK::CloudWatch::SearchExpression
Return a copy of SearchExpression with properties changed.
Constructor Details
#initialize(props) ⇒ SearchExpression
Returns a new instance of SearchExpression.
27 28 29 30 31 |
# File 'cloud_watch/search_expression.rb', line 27 def initialize(props) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::SearchExpressionProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5TZWFyY2hFeHByZXNzaW9uUHJvcHMifQ==")), "props") Jsii::Object.instance_method(:initialize).bind(self).call(props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'cloud_watch/search_expression.rb', line 33 def self.jsii_overridable_methods { :expression => { kind: :property, name: "expression", is_optional: false }, :period => { kind: :property, name: "period", 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 }, :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?
Hex color code (e.g. '#00ff00'), to use when rendering the resulting metrics in a graph. If multiple time series are returned, color is assigned to the first metric, color for the other metrics is automatically assigned.
66 67 68 |
# File 'cloud_watch/search_expression.rb', line 66 def color() jsii_get_property("color") end |
#expression ⇒ String
The search expression defining the metrics to be retrieved.
52 53 54 |
# File 'cloud_watch/search_expression.rb', line 52 def expression() jsii_get_property("expression") end |
#label ⇒ String?
The label is used as a prefix for the title of each metric returned by the search expression.
73 74 75 |
# File 'cloud_watch/search_expression.rb', line 73 def label() jsii_get_property("label") end |
#period ⇒ AWSCDK::Duration
The aggregation period for the metrics produced by the Search Expression.
59 60 61 |
# File 'cloud_watch/search_expression.rb', line 59 def period() jsii_get_property("period") end |
#search_account ⇒ String?
Account to evaluate search expressions within.
80 81 82 |
# File 'cloud_watch/search_expression.rb', line 80 def search_account() jsii_get_property("searchAccount") end |
#search_region ⇒ String?
Region to evaluate search expressions within.
87 88 89 |
# File 'cloud_watch/search_expression.rb', line 87 def search_region() jsii_get_property("searchRegion") end |
#to_metric_config ⇒ AWSCDK::CloudWatch::MetricConfig
Inspect the details of the metric object.
109 110 111 |
# File 'cloud_watch/search_expression.rb', line 109 def to_metric_config() jsii_call_method("toMetricConfig", []) end |
#to_string ⇒ String
Returns a string representation of an object.
116 117 118 |
# File 'cloud_watch/search_expression.rb', line 116 def to_string() jsii_call_method("toString", []) end |
#warnings ⇒ Array<String>?
- use warningsV2
Warnings generated by this search expression.
95 96 97 |
# File 'cloud_watch/search_expression.rb', line 95 def warnings() jsii_get_property("warnings") end |
#warnings_v2 ⇒ Hash{String => String}?
Warnings generated by this search expression.
102 103 104 |
# File 'cloud_watch/search_expression.rb', line 102 def warnings_v2() jsii_get_property("warningsV2") end |
#with(props) ⇒ AWSCDK::CloudWatch::SearchExpression
Return a copy of SearchExpression with properties changed.
All properties except expression can be changed.
126 127 128 129 130 |
# File 'cloud_watch/search_expression.rb', line 126 def with(props) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::SearchExpressionOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5TZWFyY2hFeHByZXNzaW9uT3B0aW9ucyJ9")), "props") jsii_call_method("with", [props]) end |