Class MathExpression.Builder

java.lang.Object
software.amazon.awscdk.services.cloudwatch.MathExpression.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<MathExpression>
Enclosing class:
MathExpression

@Stability(Stable) public static final class MathExpression.Builder extends Object implements software.amazon.jsii.Builder<MathExpression>
A fluent builder for MathExpression.
  • Method Details

    • create

      @Stability(Stable) public static MathExpression.Builder create()
      Returns:
      a new instance of MathExpression.Builder.
    • color

      @Stability(Stable) public MathExpression.Builder color(String color)
      Color for this metric when added to a Graph in a Dashboard.

      Default: - Automatic color

      Parameters:
      color - Color for this metric when added to a Graph in a Dashboard. This parameter is required.
      Returns:
      this
    • label

      @Stability(Stable) public MathExpression.Builder label(String 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.

      Default: - Expression value is used as label

      Parameters:
      label - Label for this expression when added to a Graph in a Dashboard. This parameter is required.
      Returns:
      this
    • period

      @Stability(Stable) public MathExpression.Builder period(Duration period)
      The period over which the expression's statistics are applied.

      This period overrides all periods in the metrics used in this math expression.

      Default: Duration.minutes(5)

      Parameters:
      period - The period over which the expression's statistics are applied. This parameter is required.
      Returns:
      this
    • searchAccount

      @Stability(Stable) public MathExpression.Builder searchAccount(String searchAccount)
      Account to evaluate search expressions within.

      Specifying a searchAccount has no effect to the account used for metrics within the expression (passed via usingMetrics).

      Default: - Deployment account.

      Parameters:
      searchAccount - Account to evaluate search expressions within. This parameter is required.
      Returns:
      this
    • searchRegion

      @Stability(Stable) public MathExpression.Builder searchRegion(String searchRegion)
      Region to evaluate search expressions within.

      Specifying a searchRegion has no effect to the region used for metrics within the expression (passed via usingMetrics).

      Default: - Deployment region.

      Parameters:
      searchRegion - Region to evaluate search expressions within. This parameter is required.
      Returns:
      this
    • expression

      @Stability(Stable) public MathExpression.Builder expression(String expression)
      The expression defining the metric.

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

      Parameters:
      expression - The expression defining the metric. This parameter is required.
      Returns:
      this
    • usingMetrics

      @Stability(Stable) public MathExpression.Builder usingMetrics(Map<String,? extends IMetric> usingMetrics)
      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 usingMetrics 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:

       IApplicationLoadBalancerMetrics metrics;
       MathExpression.Builder.create()
               .expression("m1+m2")
               .label("AlbErrors")
               .usingMetrics(Map.of(
                       "m1", metrics.custom("HTTPCode_ELB_500_Count", MetricOptions.builder()
                               .period(Duration.minutes(1)) // <- This period will be ignored
                               .statistic("Sum")
                               .label("HTTPCode_ELB_500_Count")
                               .build()),
                       "m2", metrics.custom("HTTPCode_ELB_502_Count", MetricOptions.builder()
                               .period(Duration.minutes(1)) // <- This period will be ignored
                               .statistic("Sum")
                               .label("HTTPCode_ELB_502_Count")
                               .build())))
               .period(Duration.minutes(3))
               .build();
       

      Default: - Empty map.

      Parameters:
      usingMetrics - The metrics used in the expression, in a map. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public MathExpression build()
      Specified by:
      build in interface software.amazon.jsii.Builder<MathExpression>
      Returns:
      a newly built instance of MathExpression.