Skip to content

Commit 8b556b0

Browse files
author
awstools
committed
feat(client-cloudwatch): This release adds support for CloudWatch Anomaly Detection on cross-account metrics. SingleMetricAnomalyDetector and MetricDataQuery inputs to Anomaly Detection APIs now take an optional AccountId field.
1 parent 261f787 commit 8b556b0

File tree

8 files changed

+219
-30
lines changed

8 files changed

+219
-30
lines changed

clients/client-cloudwatch/src/commands/DeleteAnomalyDetectorCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface DeleteAnomalyDetectorCommandOutput extends DeleteAnomalyDetecto
5353
* ],
5454
* Stat: "STRING_VALUE",
5555
* SingleMetricAnomalyDetector: { // SingleMetricAnomalyDetector
56+
* AccountId: "STRING_VALUE",
5657
* Namespace: "STRING_VALUE",
5758
* MetricName: "STRING_VALUE",
5859
* Dimensions: [

clients/client-cloudwatch/src/commands/DescribeAnomalyDetectorsCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export interface DescribeAnomalyDetectorsCommandOutput extends DescribeAnomalyDe
8080
* // },
8181
* // StateValue: "PENDING_TRAINING" || "TRAINED_INSUFFICIENT_DATA" || "TRAINED",
8282
* // SingleMetricAnomalyDetector: { // SingleMetricAnomalyDetector
83+
* // AccountId: "STRING_VALUE",
8384
* // Namespace: "STRING_VALUE",
8485
* // MetricName: "STRING_VALUE",
8586
* // Dimensions: [

clients/client-cloudwatch/src/commands/PutAnomalyDetectorCommand.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export interface PutAnomalyDetectorCommandOutput extends PutAnomalyDetectorOutpu
2929
/**
3030
* <p>Creates an anomaly detection model for a CloudWatch metric. You can use the model
3131
* to display a band of expected normal values when the metric is graphed.</p>
32+
* <p>If you have enabled unified cross-account observability, and this account is a monitoring
33+
* account, the metric can be in the same account or a source account. You can specify the account ID
34+
* in the object you specify in the <code>SingleMetricAnomalyDetector</code> parameter.</p>
3235
* <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Anomaly_Detection.html">CloudWatch Anomaly Detection</a>.</p>
3336
* @example
3437
* Use a bare-bones client and the command you need to make an API call.
@@ -56,6 +59,7 @@ export interface PutAnomalyDetectorCommandOutput extends PutAnomalyDetectorOutpu
5659
* MetricTimezone: "STRING_VALUE",
5760
* },
5861
* SingleMetricAnomalyDetector: { // SingleMetricAnomalyDetector
62+
* AccountId: "STRING_VALUE",
5963
* Namespace: "STRING_VALUE",
6064
* MetricName: "STRING_VALUE",
6165
* Dimensions: [

clients/client-cloudwatch/src/commands/PutCompositeAlarmCommand.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,21 @@ export interface PutCompositeAlarmCommandOutput extends __MetadataBearer {}
4141
* for the composite alarm. For example, you could create a composite
4242
* alarm that goes into ALARM state only when more than one of the underlying metric alarms
4343
* are in ALARM state.</p>
44-
* <p>Currently, the only alarm actions that can be taken by composite alarms are notifying
45-
* SNS topics.</p>
44+
* <p>Composite alarms can take the following actions:</p>
45+
* <ul>
46+
* <li>
47+
* <p>Notify Amazon SNS topics.</p>
48+
* </li>
49+
* <li>
50+
* <p>Invoke Lambda functions.</p>
51+
* </li>
52+
* <li>
53+
* <p>Create OpsItems in Systems Manager Ops Center.</p>
54+
* </li>
55+
* <li>
56+
* <p>Create incidents in Systems Manager Incident Manager.</p>
57+
* </li>
58+
* </ul>
4659
* <note>
4760
* <p>It is possible to create a loop or cycle of composite alarms, where composite alarm A depends on composite alarm B, and
4861
* composite alarm B also depends on composite alarm A. In this scenario, you can't delete any composite alarm that is part of the cycle

clients/client-cloudwatch/src/commands/PutMetricDataCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface PutMetricDataCommandOutput extends __MetadataBearer {}
3434
* take up to fifteen minutes for the metric to appear in calls to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
3535
* <p>You can publish either individual data points in the <code>Value</code> field, or
3636
* arrays of values and the number of times each value occurred during the period by using the
37-
* <code>Values</code> and <code>Counts</code> fields in the <code>MetricDatum</code> structure. Using
37+
* <code>Values</code> and <code>Counts</code> fields in the <code>MetricData</code> structure. Using
3838
* the <code>Values</code> and <code>Counts</code> method enables you to publish up to 150 values per metric
3939
* with one <code>PutMetricData</code> request, and
4040
* supports retrieving percentile statistics on this data.</p>

clients/client-cloudwatch/src/models/models_0.ts

Lines changed: 171 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,19 @@ export interface MetricMathAnomalyDetector {
408408

409409
/**
410410
* <p>Designates the CloudWatch metric and statistic that provides the time series the anomaly detector
411-
* uses as input.</p>
411+
* uses as input. If you have enabled unified cross-account observability, and this account is a monitoring
412+
* account, the metric can be in the same account or a source account.</p>
412413
* @public
413414
*/
414415
export interface SingleMetricAnomalyDetector {
416+
/**
417+
* <p>If the CloudWatch metric that provides the time series that the anomaly detector
418+
* uses as input is in another account, specify that account ID here. If you omit this parameter,
419+
* the current account is used.</p>
420+
* @public
421+
*/
422+
AccountId?: string;
423+
415424
/**
416425
* <p>The namespace of the metric to create the anomaly detection model for.</p>
417426
* @public
@@ -456,6 +465,8 @@ export type AnomalyDetectorStateValue = (typeof AnomalyDetectorStateValue)[keyof
456465
* <p>An anomaly detection model associated with a particular CloudWatch metric, statistic, or metric math expression.
457466
* You can use the model to display a band of expected, normal values
458467
* when the metric is graphed.</p>
468+
* <p>If you have enabled unified cross-account observability, and this account is a monitoring
469+
* account, the metric can be in the same account or a source account.</p>
459470
* @public
460471
*/
461472
export interface AnomalyDetector {
@@ -2421,6 +2432,7 @@ export interface GetMetricDataInput {
24212432
* <p>The order in which data points should be returned. <code>TimestampDescending</code> returns the newest data first and paginates
24222433
* when the <code>MaxDatapoints</code> limit is reached. <code>TimestampAscending</code> returns the oldest data first and paginates
24232434
* when the <code>MaxDatapoints</code> limit is reached.</p>
2435+
* <p>If you omit this parameter, the default of <code>TimestampDescending</code> is used.</p>
24242436
* @public
24252437
*/
24262438
ScanBy?: ScanBy;
@@ -3459,7 +3471,7 @@ export interface PutAnomalyDetectorInput {
34593471
* </p>
34603472
* </li>
34613473
* <li>
3462-
* <p>the <code>MetricMatchAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code>
3474+
* <p>the <code>MetricMathAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code>
34633475
* </p>
34643476
* </li>
34653477
* </ul>
@@ -3544,9 +3556,39 @@ export interface PutCompositeAlarmInput {
35443556
/**
35453557
* <p>The actions to execute when this alarm transitions to the <code>ALARM</code> state from any other state.
35463558
* Each action is specified as an Amazon Resource Name (ARN).</p>
3547-
* <p>Valid Values: <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
3559+
* <p>Valid Values: ]</p>
3560+
* <p>
3561+
* <b>Amazon SNS actions:</b>
3562+
* </p>
3563+
* <p>
3564+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
35483565
* </code>
3549-
* | <code>arn:aws:ssm:<i>region</i>:<i>account-id</i>:opsitem:<i>severity</i>
3566+
* </p>
3567+
* <p>
3568+
* <b>Lambda actions:</b>
3569+
* </p>
3570+
* <ul>
3571+
* <li>
3572+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
3573+
* </code>
3574+
* </p>
3575+
* </li>
3576+
* <li>
3577+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
3578+
* </code>
3579+
* </p>
3580+
* </li>
3581+
* <li>
3582+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
3583+
* </code>
3584+
* </p>
3585+
* </li>
3586+
* </ul>
3587+
* <p>
3588+
* <b>Systems Manager actions:</b>
3589+
* </p>
3590+
* <p>
3591+
* <code>arn:aws:ssm:<i>region</i>:<i>account-id</i>:opsitem:<i>severity</i>
35503592
* </code>
35513593
* </p>
35523594
* @public
@@ -3636,28 +3678,84 @@ export interface PutCompositeAlarmInput {
36363678
/**
36373679
* <p>The actions to execute when this alarm transitions to the <code>INSUFFICIENT_DATA</code> state from any other state.
36383680
* Each action is specified as an Amazon Resource Name (ARN).</p>
3639-
* <p>Valid Values: <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
3681+
* <p>Valid Values: ]</p>
3682+
* <p>
3683+
* <b>Amazon SNS actions:</b>
3684+
* </p>
3685+
* <p>
3686+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
36403687
* </code>
36413688
* </p>
3689+
* <p>
3690+
* <b>Lambda actions:</b>
3691+
* </p>
3692+
* <ul>
3693+
* <li>
3694+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
3695+
* </code>
3696+
* </p>
3697+
* </li>
3698+
* <li>
3699+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
3700+
* </code>
3701+
* </p>
3702+
* </li>
3703+
* <li>
3704+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
3705+
* </code>
3706+
* </p>
3707+
* </li>
3708+
* </ul>
36423709
* @public
36433710
*/
36443711
InsufficientDataActions?: string[];
36453712

36463713
/**
36473714
* <p>The actions to execute when this alarm transitions to an <code>OK</code> state
36483715
* from any other state. Each action is specified as an Amazon Resource Name (ARN).</p>
3649-
* <p>Valid Values: <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
3716+
* <p>Valid Values: ]</p>
3717+
* <p>
3718+
* <b>Amazon SNS actions:</b>
3719+
* </p>
3720+
* <p>
3721+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
36503722
* </code>
36513723
* </p>
3724+
* <p>
3725+
* <b>Lambda actions:</b>
3726+
* </p>
3727+
* <ul>
3728+
* <li>
3729+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
3730+
* </code>
3731+
* </p>
3732+
* </li>
3733+
* <li>
3734+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
3735+
* </code>
3736+
* </p>
3737+
* </li>
3738+
* <li>
3739+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
3740+
* </code>
3741+
* </p>
3742+
* </li>
3743+
* </ul>
36523744
* @public
36533745
*/
36543746
OKActions?: string[];
36553747

36563748
/**
3657-
* <p>A list of key-value pairs to associate with the composite alarm. You can associate as many as 50 tags with an alarm.</p>
3658-
* <p>Tags can help you organize and categorize your
3659-
* resources. You can also use them to scope user permissions, by granting a user permission to access or change only resources with
3660-
* certain tag values.</p>
3749+
* <p>A list of key-value pairs to associate with the alarm. You can associate as many as 50 tags with an alarm.
3750+
* To be able to associate tags with the alarm when you create the alarm, you must
3751+
* have the <code>cloudwatch:TagResource</code> permission.</p>
3752+
* <p>Tags can help you organize and categorize your resources. You can also use them to scope user
3753+
* permissions by granting a user
3754+
* permission to access or change only resources with certain tag values.</p>
3755+
* <p>If you are using this operation to update an existing alarm, any tags
3756+
* you specify in this parameter are ignored. To change the tags of an existing alarm, use
3757+
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html">TagResource</a>
3758+
* or <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_UntagResource.html">UntagResource</a>.</p>
36613759
* @public
36623760
*/
36633761
Tags?: Tag[];
@@ -3981,12 +4079,32 @@ export interface PutMetricAlarmInput {
39814079
* </li>
39824080
* </ul>
39834081
* <p>
4082+
* <b>Lambda actions:</b>
4083+
* </p>
4084+
* <ul>
4085+
* <li>
4086+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
4087+
* </code>
4088+
* </p>
4089+
* </li>
4090+
* <li>
4091+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
4092+
* </code>
4093+
* </p>
4094+
* </li>
4095+
* <li>
4096+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
4097+
* </code>
4098+
* </p>
4099+
* </li>
4100+
* </ul>
4101+
* <p>
39844102
* <b>SNS notification action:</b>
39854103
* </p>
39864104
* <ul>
39874105
* <li>
39884106
* <p>
3989-
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>:autoScalingGroupName/<i>group-friendly-name</i>:policyName/<i>policy-friendly-name</i>
4107+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
39904108
* </code>
39914109
* </p>
39924110
* </li>
@@ -4072,12 +4190,32 @@ export interface PutMetricAlarmInput {
40724190
* </li>
40734191
* </ul>
40744192
* <p>
4193+
* <b>Lambda actions:</b>
4194+
* </p>
4195+
* <ul>
4196+
* <li>
4197+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
4198+
* </code>
4199+
* </p>
4200+
* </li>
4201+
* <li>
4202+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
4203+
* </code>
4204+
* </p>
4205+
* </li>
4206+
* <li>
4207+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
4208+
* </code>
4209+
* </p>
4210+
* </li>
4211+
* </ul>
4212+
* <p>
40754213
* <b>SNS notification action:</b>
40764214
* </p>
40774215
* <ul>
40784216
* <li>
40794217
* <p>
4080-
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>:autoScalingGroupName/<i>group-friendly-name</i>:policyName/<i>policy-friendly-name</i>
4218+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
40814219
* </code>
40824220
* </p>
40834221
* </li>
@@ -4163,12 +4301,32 @@ export interface PutMetricAlarmInput {
41634301
* </li>
41644302
* </ul>
41654303
* <p>
4304+
* <b>Lambda actions:</b>
4305+
* </p>
4306+
* <ul>
4307+
* <li>
4308+
* <p>Invoke the latest version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>
4309+
* </code>
4310+
* </p>
4311+
* </li>
4312+
* <li>
4313+
* <p>Invoke a specific version of a Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>version-number</i>
4314+
* </code>
4315+
* </p>
4316+
* </li>
4317+
* <li>
4318+
* <p>Invoke a function by using an alias Lambda function: <code>arn:aws:lambda:<i>region</i>:<i>account-id</i>:function:<i>function-name</i>:<i>alias-name</i>
4319+
* </code>
4320+
* </p>
4321+
* </li>
4322+
* </ul>
4323+
* <p>
41664324
* <b>SNS notification action:</b>
41674325
* </p>
41684326
* <ul>
41694327
* <li>
41704328
* <p>
4171-
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>:autoScalingGroupName/<i>group-friendly-name</i>:policyName/<i>policy-friendly-name</i>
4329+
* <code>arn:aws:sns:<i>region</i>:<i>account-id</i>:<i>sns-topic-name</i>
41724330
* </code>
41734331
* </p>
41744332
* </li>

clients/client-cloudwatch/src/protocols/Aws_query.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,6 +3552,9 @@ const se_SetAlarmStateInput = (input: SetAlarmStateInput, context: __SerdeContex
35523552
*/
35533553
const se_SingleMetricAnomalyDetector = (input: SingleMetricAnomalyDetector, context: __SerdeContext): any => {
35543554
const entries: any = {};
3555+
if (input[_AI] != null) {
3556+
entries[_AI] = input[_AI];
3557+
}
35553558
if (input[_N] != null) {
35563559
entries[_N] = input[_N];
35573560
}
@@ -5382,6 +5385,9 @@ const de_ResourceNotFoundException = (output: any, context: __SerdeContext): Res
53825385
*/
53835386
const de_SingleMetricAnomalyDetector = (output: any, context: __SerdeContext): SingleMetricAnomalyDetector => {
53845387
const contents: any = {};
5388+
if (output[_AI] != null) {
5389+
contents[_AI] = __expectString(output[_AI]);
5390+
}
53855391
if (output[_N] != null) {
53865392
contents[_N] = __expectString(output[_N]);
53875393
}

0 commit comments

Comments
 (0)