Skip to content
v2.278.0

MetricMathAnomalyDetectorProperty Struct ​

Indicates the CloudWatch math expression that provides the time series the anomaly detector uses as input.

The designated math expression must return a single time series.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
const metricMathAnomalyDetectorProperty: cloudwatch.CfnAnomalyDetector.MetricMathAnomalyDetectorProperty = {
  metricDataQueries: [{
    id: 'id',

    // the properties below are optional
    accountId: 'accountId',
    expression: 'expression',
    label: 'label',
    metricStat: {
      metric: {
        metricName: 'metricName',
        namespace: 'namespace',

        // the properties below are optional
        dimensions: [{
          name: 'name',
          value: 'value',
        }],
      },
      period: 123,
      stat: 'stat',

      // the properties below are optional
      unit: 'unit',
    },
    period: 123,
    returnData: false,
  }],
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_cloudwatch as cloudwatch

metric_math_anomaly_detector_property = cloudwatch.CfnAnomalyDetector.MetricMathAnomalyDetectorProperty(
    metric_data_queries=[cloudwatch.CfnAnomalyDetector.MetricDataQueryProperty(
        id="id",

        # the properties below are optional
        account_id="accountId",
        expression="expression",
        label="label",
        metric_stat=cloudwatch.CfnAnomalyDetector.MetricStatProperty(
            metric=cloudwatch.CfnAnomalyDetector.MetricProperty(
                metric_name="metricName",
                namespace="namespace",

                # the properties below are optional
                dimensions=[cloudwatch.CfnAnomalyDetector.DimensionProperty(
                    name="name",
                    value="value"
                )]
            ),
            period=123,
            stat="stat",

            # the properties below are optional
            unit="unit"
        ),
        period=123,
        return_data=False
    )]
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cloudwatch.*;

MetricMathAnomalyDetectorProperty metricMathAnomalyDetectorProperty = MetricMathAnomalyDetectorProperty.builder()
        .metricDataQueries(List.of(MetricDataQueryProperty.builder()
                .id("id")

                // the properties below are optional
                .accountId("accountId")
                .expression("expression")
                .label("label")
                .metricStat(MetricStatProperty.builder()
                        .metric(MetricProperty.builder()
                                .metricName("metricName")
                                .namespace("namespace")

                                // the properties below are optional
                                .dimensions(List.of(DimensionProperty.builder()
                                        .name("name")
                                        .value("value")
                                        .build()))
                                .build())
                        .period(123)
                        .stat("stat")

                        // the properties below are optional
                        .unit("unit")
                        .build())
                .period(123)
                .returnData(false)
                .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.CloudWatch;

var metricMathAnomalyDetectorProperty = new MetricMathAnomalyDetectorProperty {
    MetricDataQueries = new [] { new MetricDataQueryProperty {
        Id = "id",

        // the properties below are optional
        AccountId = "accountId",
        Expression = "expression",
        Label = "label",
        MetricStat = new MetricStatProperty {
            Metric = new MetricProperty {
                MetricName = "metricName",
                Namespace = "namespace",

                // the properties below are optional
                Dimensions = new [] { new DimensionProperty {
                    Name = "name",
                    Value = "value"
                } }
            },
            Period = 123,
            Stat = "stat",

            // the properties below are optional
            Unit = "unit"
        },
        Period = 123,
        ReturnData = false
    } }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

metricMathAnomalyDetectorProperty := &MetricMathAnomalyDetectorProperty{
	MetricDataQueries: []interface{}{
		&MetricDataQueryProperty{
			Id: jsii.String("id"),

			// the properties below are optional
			AccountId: jsii.String("accountId"),
			Expression: jsii.String("expression"),
			Label: jsii.String("label"),
			MetricStat: &MetricStatProperty{
				Metric: &MetricProperty{
					MetricName: jsii.String("metricName"),
					Namespace: jsii.String("namespace"),

					// the properties below are optional
					Dimensions: []interface{}{
						&DimensionProperty{
							Name: jsii.String("name"),
							Value: jsii.String("value"),
						},
					},
				},
				Period: jsii.Number(123),
				Stat: jsii.String("stat"),

				// the properties below are optional
				Unit: jsii.String("unit"),
			},
			Period: jsii.Number(123),
			ReturnData: jsii.Boolean(false),
		},
	},
}

Properties ​

metricDataQueriesoptionalIResolvable | IResolvable | CfnAnomalyDetector.MetricDataQueryProperty[]metric_data_queriesoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, MetricDataQueryProperty]]]metricDataQueriesoptionalIResolvableMetricDataQueriesoptionalIResolvableMetricDataQueriesoptionalinterface{} #
An array of metric data query structures that enables you to create an anomaly detector based on the result of a metric math expression.
notes

Each item in MetricDataQueries gets a metric or performs a math expression. One item in MetricDataQueries is the expression that provides the time series that the anomaly detector uses as input. Designate the expression by setting ReturnData to true for this object in the array. For all other expressions and metrics, set ReturnData to false . The designated expression must return a single time series.