From e0d291a58ee664a5cbfb2215f70d31b2a6516c47 Mon Sep 17 00:00:00 2001 From: awstools Date: Thu, 11 Apr 2024 18:13:53 +0000 Subject: [PATCH] feat(client-cloudwatch): This release adds support for Metric Characteristics for CloudWatch Anomaly Detection. Anomaly Detector now takes Metric Characteristics object with Periodic Spikes boolean field that tells Anomaly Detection that spikes that repeat at the same time every week are part of the expected pattern. --- .../DescribeAnomalyDetectorsCommand.ts | 3 ++ .../src/commands/PutAnomalyDetectorCommand.ts | 3 ++ .../client-cloudwatch/src/models/models_0.ts | 35 +++++++++++++++++-- .../src/protocols/Aws_query.ts | 35 +++++++++++++++++++ .../sdk-codegen/aws-models/cloudwatch.json | 31 +++++++++++++++- 5 files changed, 104 insertions(+), 3 deletions(-) diff --git a/clients/client-cloudwatch/src/commands/DescribeAnomalyDetectorsCommand.ts b/clients/client-cloudwatch/src/commands/DescribeAnomalyDetectorsCommand.ts index fc0e2ee5b99f..6110ff063bb0 100644 --- a/clients/client-cloudwatch/src/commands/DescribeAnomalyDetectorsCommand.ts +++ b/clients/client-cloudwatch/src/commands/DescribeAnomalyDetectorsCommand.ts @@ -79,6 +79,9 @@ export interface DescribeAnomalyDetectorsCommandOutput extends DescribeAnomalyDe * // MetricTimezone: "STRING_VALUE", * // }, * // StateValue: "PENDING_TRAINING" || "TRAINED_INSUFFICIENT_DATA" || "TRAINED", + * // MetricCharacteristics: { // MetricCharacteristics + * // PeriodicSpikes: true || false, + * // }, * // SingleMetricAnomalyDetector: { // SingleMetricAnomalyDetector * // AccountId: "STRING_VALUE", * // Namespace: "STRING_VALUE", diff --git a/clients/client-cloudwatch/src/commands/PutAnomalyDetectorCommand.ts b/clients/client-cloudwatch/src/commands/PutAnomalyDetectorCommand.ts index 94d0d6c50410..140f877b60ba 100644 --- a/clients/client-cloudwatch/src/commands/PutAnomalyDetectorCommand.ts +++ b/clients/client-cloudwatch/src/commands/PutAnomalyDetectorCommand.ts @@ -58,6 +58,9 @@ export interface PutAnomalyDetectorCommandOutput extends PutAnomalyDetectorOutpu * ], * MetricTimezone: "STRING_VALUE", * }, + * MetricCharacteristics: { // MetricCharacteristics + * PeriodicSpikes: true || false, + * }, * SingleMetricAnomalyDetector: { // SingleMetricAnomalyDetector * AccountId: "STRING_VALUE", * Namespace: "STRING_VALUE", diff --git a/clients/client-cloudwatch/src/models/models_0.ts b/clients/client-cloudwatch/src/models/models_0.ts index 305348aa3b7e..b43701123a82 100644 --- a/clients/client-cloudwatch/src/models/models_0.ts +++ b/clients/client-cloudwatch/src/models/models_0.ts @@ -164,6 +164,22 @@ export interface Dimension { Value: string | undefined; } +/** + *

This object includes parameters that you can use to provide information to + * CloudWatch to help it build more accurate anomaly detection models.

+ * @public + */ +export interface MetricCharacteristics { + /** + *

Set this parameter to true if values for this metric consistently include spikes + * that should not be considered to be anomalies. With this set to true, CloudWatch will expect + * to see spikes that occurred consistently during the model training period, and won't flag future similar spikes + * as anomalies.

+ * @public + */ + PeriodicSpikes?: boolean; +} + /** *

Represents a specific metric.

* @public @@ -512,12 +528,19 @@ export interface AnomalyDetector { Configuration?: AnomalyDetectorConfiguration; /** - *

The current status of the anomaly detector's training. The possible values are TRAINED | PENDING_TRAINING | TRAINED_INSUFFICIENT_DATA - *

+ *

The current status of the anomaly detector's training.

* @public */ StateValue?: AnomalyDetectorStateValue; + /** + *

This object includes parameters that you can use to provide information about your metric to + * CloudWatch to help it build more accurate anomaly detection models. Currently, it includes + * the PeriodicSpikes parameter.

+ * @public + */ + MetricCharacteristics?: MetricCharacteristics; + /** *

The CloudWatch metric and statistic for this anomaly detector.

* @public @@ -3445,6 +3468,14 @@ export interface PutAnomalyDetectorInput { */ Configuration?: AnomalyDetectorConfiguration; + /** + *

Use this object to include parameters to provide information about your metric to + * CloudWatch to help it build more accurate anomaly detection models. Currently, it includes + * the PeriodicSpikes parameter.

+ * @public + */ + MetricCharacteristics?: MetricCharacteristics; + /** *

A single metric anomaly detector to be created.

*

When using SingleMetricAnomalyDetector, diff --git a/clients/client-cloudwatch/src/protocols/Aws_query.ts b/clients/client-cloudwatch/src/protocols/Aws_query.ts index 3b145fa71ca2..e93feaf34997 100644 --- a/clients/client-cloudwatch/src/protocols/Aws_query.ts +++ b/clients/client-cloudwatch/src/protocols/Aws_query.ts @@ -180,6 +180,7 @@ import { MessageData, Metric, MetricAlarm, + MetricCharacteristics, MetricDataQuery, MetricDataResult, MetricDatum, @@ -2771,6 +2772,17 @@ const se_Metric = (input: Metric, context: __SerdeContext): any => { return entries; }; +/** + * serializeAws_queryMetricCharacteristics + */ +const se_MetricCharacteristics = (input: MetricCharacteristics, context: __SerdeContext): any => { + const entries: any = {}; + if (input[_PS] != null) { + entries[_PS] = input[_PS]; + } + return entries; +}; + /** * serializeAws_queryMetricData */ @@ -3152,6 +3164,13 @@ const se_PutAnomalyDetectorInput = (input: PutAnomalyDetectorInput, context: __S entries[loc] = value; }); } + if (input[_MC] != null) { + const memberEntries = se_MetricCharacteristics(input[_MC], context); + Object.entries(memberEntries).forEach(([key, value]) => { + const loc = `MetricCharacteristics.${key}`; + entries[loc] = value; + }); + } if (input[_SMAD] != null) { const memberEntries = se_SingleMetricAnomalyDetector(input[_SMAD], context); Object.entries(memberEntries).forEach(([key, value]) => { @@ -3818,6 +3837,9 @@ const de_AnomalyDetector = (output: any, context: __SerdeContext): AnomalyDetect if (output[_SV] != null) { contents[_SV] = __expectString(output[_SV]); } + if (output[_MC] != null) { + contents[_MC] = de_MetricCharacteristics(output[_MC], context); + } if (output[_SMAD] != null) { contents[_SMAD] = de_SingleMetricAnomalyDetector(output[_SMAD], context); } @@ -4939,6 +4961,17 @@ const de_MetricAlarms = (output: any, context: __SerdeContext): MetricAlarm[] => }); }; +/** + * deserializeAws_queryMetricCharacteristics + */ +const de_MetricCharacteristics = (output: any, context: __SerdeContext): MetricCharacteristics => { + const contents: any = {}; + if (output[_PS] != null) { + contents[_PS] = __parseBoolean(output[_PS]); + } + return contents; +}; + /** * deserializeAws_queryMetricDataQueries */ @@ -5626,6 +5659,7 @@ const _LTFR = "ListTagsForResource"; const _LUD = "LastUpdateDate"; const _M = "Metrics"; const _MA = "MetricAlarms"; +const _MC = "MetricCharacteristics"; const _MCC = "MaxContributorCount"; const _MCV = "MaxContributorValue"; const _MD = "MaxDatapoints"; @@ -5668,6 +5702,7 @@ const _PMD = "PutMetricData"; const _PMIR = "PutManagedInsightRules"; const _PMS = "PutMetricStream"; const _POAN = "ParentsOfAlarmName"; +const _PS = "PeriodicSpikes"; const _RA = "RecentlyActive"; const _RARN = "ResourceARN"; const _RAo = "RoleArn"; diff --git a/codegen/sdk-codegen/aws-models/cloudwatch.json b/codegen/sdk-codegen/aws-models/cloudwatch.json index bd3454c66416..bec6629e39d3 100644 --- a/codegen/sdk-codegen/aws-models/cloudwatch.json +++ b/codegen/sdk-codegen/aws-models/cloudwatch.json @@ -269,7 +269,13 @@ "StateValue": { "target": "com.amazonaws.cloudwatch#AnomalyDetectorStateValue", "traits": { - "smithy.api#documentation": "

The current status of the anomaly detector's training. The possible values are TRAINED | PENDING_TRAINING | TRAINED_INSUFFICIENT_DATA\n

" + "smithy.api#documentation": "

The current status of the anomaly detector's training.

" + } + }, + "MetricCharacteristics": { + "target": "com.amazonaws.cloudwatch#MetricCharacteristics", + "traits": { + "smithy.api#documentation": "

This object includes parameters that you can use to provide information about your metric to \n\t\t\tCloudWatch to help it build more accurate anomaly detection models. Currently, it includes\n\t\t\tthe PeriodicSpikes parameter.

" } }, "SingleMetricAnomalyDetector": { @@ -4838,6 +4844,20 @@ "target": "com.amazonaws.cloudwatch#MetricAlarm" } }, + "com.amazonaws.cloudwatch#MetricCharacteristics": { + "type": "structure", + "members": { + "PeriodicSpikes": { + "target": "com.amazonaws.cloudwatch#PeriodicSpikes", + "traits": { + "smithy.api#documentation": "

Set this parameter to true if values for this metric consistently include spikes\n\t\t\tthat should not be considered to be anomalies. With this set to true, CloudWatch will expect \n\t\t\tto see spikes that occurred consistently during the model training period, and won't flag future similar spikes\n\t\t\tas anomalies.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

This object includes parameters that you can use to provide information to \n\t\t\tCloudWatch to help it build more accurate anomaly detection models.

" + } + }, "com.amazonaws.cloudwatch#MetricData": { "type": "list", "member": { @@ -5402,6 +5422,9 @@ } } }, + "com.amazonaws.cloudwatch#PeriodicSpikes": { + "type": "boolean" + }, "com.amazonaws.cloudwatch#PutAnomalyDetector": { "type": "operation", "input": { @@ -5476,6 +5499,12 @@ "smithy.api#documentation": "

The configuration specifies details about how the \n\t\t\tanomaly detection model is to be trained, including \n\t\t\ttime ranges to exclude when training and updating the model.\n\t\t\tYou can specify as many as 10 time ranges.

\n

The configuration can also include the time zone to use for \n\t\t\tthe metric.

" } }, + "MetricCharacteristics": { + "target": "com.amazonaws.cloudwatch#MetricCharacteristics", + "traits": { + "smithy.api#documentation": "

Use this object to include parameters to provide information about your metric to \n\t\t\tCloudWatch to help it build more accurate anomaly detection models. Currently, it includes\n\t\t\tthe PeriodicSpikes parameter.

" + } + }, "SingleMetricAnomalyDetector": { "target": "com.amazonaws.cloudwatch#SingleMetricAnomalyDetector", "traits": {