Class SearchExpression
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.cloudwatch.SearchExpression
- All Implemented Interfaces:
IMetric
,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)",
date="2025-07-29T17:50:57.116Z")
@Stability(Stable)
public class SearchExpression
extends software.amazon.jsii.JsiiObject
implements IMetric
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:
SearchExpression searchExpression = SearchExpression.Builder.create() .expression("SEARCH('{AWS/EC2,InstanceId} CPUUtilization', 'Average', 300)") .label("EC2 CPU Utilization") .period(Duration.minutes(5)) .build();
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.
Example:
SearchExpression cpuUtilization = SearchExpression.Builder.create() .expression("SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 900)") .label("EC2 CPU Utilization") .color("#ff7f0e") .build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudwatch.IMetric
IMetric.Jsii$Default, IMetric.Jsii$Proxy
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SearchExpression
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
SearchExpression
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptiongetColor()
Hex color code (e.g.The search expression defining the metrics to be retrieved.getLabel()
The label is used as a prefix for the title of each metric returned by the search expression.The aggregation period for the metrics produced by the Search Expression.Account to evaluate search expressions within.Region to evaluate search expressions within.Deprecated.use warningsV2Warnings generated by this search expression.Inspect the details of the metric object.toString()
Returns a string representation of an object.with
(SearchExpressionOptions props) Return a copy of SearchExpression with properties changed.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
SearchExpression
protected SearchExpression(software.amazon.jsii.JsiiObjectRef objRef) -
SearchExpression
protected SearchExpression(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
SearchExpression
- Parameters:
props
- This parameter is required.
-
-
Method Details
-
toMetricConfig
Inspect the details of the metric object.- Specified by:
toMetricConfig
in interfaceIMetric
-
toString
Returns a string representation of an object. -
with
Return a copy of SearchExpression with properties changed.All properties except expression can be changed.
- Parameters:
props
- The set of properties to change. This parameter is required.
-
getExpression
The search expression defining the metrics to be retrieved. -
getPeriod
The aggregation period for the metrics produced by the Search Expression. -
getColor
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. -
getLabel
The label is used as a prefix for the title of each metric returned by the search expression. -
getSearchAccount
Account to evaluate search expressions within. -
getSearchRegion
Region to evaluate search expressions within. -
getWarnings
Deprecated.- use warningsV2
(deprecated) Warnings generated by this search expression.- Specified by:
getWarnings
in interfaceIMetric
-
getWarningsV2
Warnings generated by this search expression.- Specified by:
getWarningsV2
in interfaceIMetric
-