Skip to content

Commit

Permalink
feat(client-cloudwatch): This release adds support for Metric Charact…
Browse files Browse the repository at this point in the history
…eristics 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.
  • Loading branch information
awstools committed Apr 11, 2024
1 parent 1061555 commit e0d291a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 33 additions & 2 deletions clients/client-cloudwatch/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ export interface Dimension {
Value: string | undefined;
}

/**
* <p>This object includes parameters that you can use to provide information to
* CloudWatch to help it build more accurate anomaly detection models.</p>
* @public
*/
export interface MetricCharacteristics {
/**
* <p>Set this parameter to <code>true</code> if values for this metric consistently include spikes
* that should not be considered to be anomalies. With this set to <code>true</code>, CloudWatch will expect
* to see spikes that occurred consistently during the model training period, and won't flag future similar spikes
* as anomalies.</p>
* @public
*/
PeriodicSpikes?: boolean;
}

/**
* <p>Represents a specific metric.</p>
* @public
Expand Down Expand Up @@ -512,12 +528,19 @@ export interface AnomalyDetector {
Configuration?: AnomalyDetectorConfiguration;

/**
* <p>The current status of the anomaly detector's training. The possible values are <code>TRAINED | PENDING_TRAINING | TRAINED_INSUFFICIENT_DATA</code>
* </p>
* <p>The current status of the anomaly detector's training.</p>
* @public
*/
StateValue?: AnomalyDetectorStateValue;

/**
* <p>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 <code>PeriodicSpikes</code> parameter.</p>
* @public
*/
MetricCharacteristics?: MetricCharacteristics;

/**
* <p>The CloudWatch metric and statistic for this anomaly detector.</p>
* @public
Expand Down Expand Up @@ -3445,6 +3468,14 @@ export interface PutAnomalyDetectorInput {
*/
Configuration?: AnomalyDetectorConfiguration;

/**
* <p>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 <code>PeriodicSpikes</code> parameter.</p>
* @public
*/
MetricCharacteristics?: MetricCharacteristics;

/**
* <p>A single metric anomaly detector to be created.</p>
* <p>When using <code>SingleMetricAnomalyDetector</code>,
Expand Down
35 changes: 35 additions & 0 deletions clients/client-cloudwatch/src/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ import {
MessageData,
Metric,
MetricAlarm,
MetricCharacteristics,
MetricDataQuery,
MetricDataResult,
MetricDatum,
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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]) => {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
31 changes: 30 additions & 1 deletion codegen/sdk-codegen/aws-models/cloudwatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@
"StateValue": {
"target": "com.amazonaws.cloudwatch#AnomalyDetectorStateValue",
"traits": {
"smithy.api#documentation": "<p>The current status of the anomaly detector's training. The possible values are <code>TRAINED | PENDING_TRAINING | TRAINED_INSUFFICIENT_DATA</code>\n </p>"
"smithy.api#documentation": "<p>The current status of the anomaly detector's training.</p>"
}
},
"MetricCharacteristics": {
"target": "com.amazonaws.cloudwatch#MetricCharacteristics",
"traits": {
"smithy.api#documentation": "<p>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 <code>PeriodicSpikes</code> parameter.</p>"
}
},
"SingleMetricAnomalyDetector": {
Expand Down Expand Up @@ -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": "<p>Set this parameter to <code>true</code> if values for this metric consistently include spikes\n\t\t\tthat should not be considered to be anomalies. With this set to <code>true</code>, 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.</p>"
}
}
},
"traits": {
"smithy.api#documentation": "<p>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.</p>"
}
},
"com.amazonaws.cloudwatch#MetricData": {
"type": "list",
"member": {
Expand Down Expand Up @@ -5402,6 +5422,9 @@
}
}
},
"com.amazonaws.cloudwatch#PeriodicSpikes": {
"type": "boolean"
},
"com.amazonaws.cloudwatch#PutAnomalyDetector": {
"type": "operation",
"input": {
Expand Down Expand Up @@ -5476,6 +5499,12 @@
"smithy.api#documentation": "<p>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.</p>\n <p>The configuration can also include the time zone to use for \n\t\t\tthe metric.</p>"
}
},
"MetricCharacteristics": {
"target": "com.amazonaws.cloudwatch#MetricCharacteristics",
"traits": {
"smithy.api#documentation": "<p>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 <code>PeriodicSpikes</code> parameter.</p>"
}
},
"SingleMetricAnomalyDetector": {
"target": "com.amazonaws.cloudwatch#SingleMetricAnomalyDetector",
"traits": {
Expand Down

0 comments on commit e0d291a

Please sign in to comment.