Class: AWSCDK::CloudWatch::SearchExpression

Inherits:
Jsii::Object
  • Object
show all
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

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_methodsObject



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

#colorString?

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.

Returns:

  • (String, nil)


66
67
68
# File 'cloud_watch/search_expression.rb', line 66

def color()
  jsii_get_property("color")
end

#expressionString

The search expression defining the metrics to be retrieved.

Returns:

  • (String)


52
53
54
# File 'cloud_watch/search_expression.rb', line 52

def expression()
  jsii_get_property("expression")
end

#labelString?

The label is used as a prefix for the title of each metric returned by the search expression.

Returns:

  • (String, nil)


73
74
75
# File 'cloud_watch/search_expression.rb', line 73

def label()
  jsii_get_property("label")
end

#periodAWSCDK::Duration

The aggregation period for the metrics produced by the Search Expression.

Returns:



59
60
61
# File 'cloud_watch/search_expression.rb', line 59

def period()
  jsii_get_property("period")
end

#search_accountString?

Account to evaluate search expressions within.

Returns:

  • (String, nil)


80
81
82
# File 'cloud_watch/search_expression.rb', line 80

def ()
  jsii_get_property("searchAccount")
end

#search_regionString?

Region to evaluate search expressions within.

Returns:

  • (String, nil)


87
88
89
# File 'cloud_watch/search_expression.rb', line 87

def search_region()
  jsii_get_property("searchRegion")
end

#to_metric_configAWSCDK::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_stringString

Returns a string representation of an object.

Returns:

  • (String)


116
117
118
# File 'cloud_watch/search_expression.rb', line 116

def to_string()
  jsii_call_method("toString", [])
end

#warningsArray<String>?

Deprecated.
  • use warningsV2

Warnings generated by this search expression.

Returns:

  • (Array<String>, nil)


95
96
97
# File 'cloud_watch/search_expression.rb', line 95

def warnings()
  jsii_get_property("warnings")
end

#warnings_v2Hash{String => String}?

Warnings generated by this search expression.

Returns:

  • (Hash{String => String}, nil)


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.

Parameters:

Returns:

  • (AWSCDK::CloudWatch::SearchExpression)


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