Skip to content

Commit 090c700

Browse files
author
awstools
committed
feat(client-cloudwatch-logs): CloudWatchLogs launches GetLogObject API with streaming support for efficient log data retrieval. Logs added support for new AccountPolicy type METRIC_EXTRACTION_POLICY. For more information, see CloudWatch Logs API documentation
1 parent 218ebbc commit 090c700

File tree

12 files changed

+622
-29
lines changed

12 files changed

+622
-29
lines changed

clients/client-cloudwatch-logs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,14 @@ GetLogGroupFields
652652

653653
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/command/GetLogGroupFieldsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudwatch-logs/Interface/GetLogGroupFieldsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudwatch-logs/Interface/GetLogGroupFieldsCommandOutput/)
654654

655+
</details>
656+
<details>
657+
<summary>
658+
GetLogObject
659+
</summary>
660+
661+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/command/GetLogObjectCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudwatch-logs/Interface/GetLogObjectCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudwatch-logs/Interface/GetLogObjectCommandOutput/)
662+
655663
</details>
656664
<details>
657665
<summary>

clients/client-cloudwatch-logs/src/CloudWatchLogs.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ import {
259259
GetLogGroupFieldsCommandInput,
260260
GetLogGroupFieldsCommandOutput,
261261
} from "./commands/GetLogGroupFieldsCommand";
262+
import {
263+
GetLogObjectCommand,
264+
GetLogObjectCommandInput,
265+
GetLogObjectCommandOutput,
266+
} from "./commands/GetLogObjectCommand";
262267
import {
263268
GetLogRecordCommand,
264269
GetLogRecordCommandInput,
@@ -487,6 +492,7 @@ const commands = {
487492
GetLogAnomalyDetectorCommand,
488493
GetLogEventsCommand,
489494
GetLogGroupFieldsCommand,
495+
GetLogObjectCommand,
490496
GetLogRecordCommand,
491497
GetQueryResultsCommand,
492498
GetTransformerCommand,
@@ -1386,6 +1392,17 @@ export interface CloudWatchLogs {
13861392
cb: (err: any, data?: GetLogGroupFieldsCommandOutput) => void
13871393
): void;
13881394

1395+
/**
1396+
* @see {@link GetLogObjectCommand}
1397+
*/
1398+
getLogObject(args: GetLogObjectCommandInput, options?: __HttpHandlerOptions): Promise<GetLogObjectCommandOutput>;
1399+
getLogObject(args: GetLogObjectCommandInput, cb: (err: any, data?: GetLogObjectCommandOutput) => void): void;
1400+
getLogObject(
1401+
args: GetLogObjectCommandInput,
1402+
options: __HttpHandlerOptions,
1403+
cb: (err: any, data?: GetLogObjectCommandOutput) => void
1404+
): void;
1405+
13891406
/**
13901407
* @see {@link GetLogRecordCommand}
13911408
*/

clients/client-cloudwatch-logs/src/CloudWatchLogsClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ import {
192192
} from "./commands/GetLogAnomalyDetectorCommand";
193193
import { GetLogEventsCommandInput, GetLogEventsCommandOutput } from "./commands/GetLogEventsCommand";
194194
import { GetLogGroupFieldsCommandInput, GetLogGroupFieldsCommandOutput } from "./commands/GetLogGroupFieldsCommand";
195+
import { GetLogObjectCommandInput, GetLogObjectCommandOutput } from "./commands/GetLogObjectCommand";
195196
import { GetLogRecordCommandInput, GetLogRecordCommandOutput } from "./commands/GetLogRecordCommand";
196197
import { GetQueryResultsCommandInput, GetQueryResultsCommandOutput } from "./commands/GetQueryResultsCommand";
197198
import { GetTransformerCommandInput, GetTransformerCommandOutput } from "./commands/GetTransformerCommand";
@@ -327,6 +328,7 @@ export type ServiceInputTypes =
327328
| GetLogAnomalyDetectorCommandInput
328329
| GetLogEventsCommandInput
329330
| GetLogGroupFieldsCommandInput
331+
| GetLogObjectCommandInput
330332
| GetLogRecordCommandInput
331333
| GetQueryResultsCommandInput
332334
| GetTransformerCommandInput
@@ -422,6 +424,7 @@ export type ServiceOutputTypes =
422424
| GetLogAnomalyDetectorCommandOutput
423425
| GetLogEventsCommandOutput
424426
| GetLogGroupFieldsCommandOutput
427+
| GetLogObjectCommandOutput
425428
| GetLogRecordCommandOutput
426429
| GetQueryResultsCommandOutput
427430
| GetTransformerCommandOutput

clients/client-cloudwatch-logs/src/commands/DeleteAccountPolicyCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface DeleteAccountPolicyCommandOutput extends __MetadataBearer {}
6464
* const client = new CloudWatchLogsClient(config);
6565
* const input = { // DeleteAccountPolicyRequest
6666
* policyName: "STRING_VALUE", // required
67-
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY", // required
67+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY" || "METRIC_EXTRACTION_POLICY", // required
6868
* };
6969
* const command = new DeleteAccountPolicyCommand(input);
7070
* const response = await client.send(command);

clients/client-cloudwatch-logs/src/commands/DescribeAccountPoliciesCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export interface DescribeAccountPoliciesCommandOutput extends DescribeAccountPol
5858
* // const { CloudWatchLogsClient, DescribeAccountPoliciesCommand } = require("@aws-sdk/client-cloudwatch-logs"); // CommonJS import
5959
* const client = new CloudWatchLogsClient(config);
6060
* const input = { // DescribeAccountPoliciesRequest
61-
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY", // required
61+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY" || "METRIC_EXTRACTION_POLICY", // required
6262
* policyName: "STRING_VALUE",
6363
* accountIdentifiers: [ // AccountIds
6464
* "STRING_VALUE",
@@ -73,7 +73,7 @@ export interface DescribeAccountPoliciesCommandOutput extends DescribeAccountPol
7373
* // policyName: "STRING_VALUE",
7474
* // policyDocument: "STRING_VALUE",
7575
* // lastUpdatedTime: Number("long"),
76-
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY",
76+
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY" || "METRIC_EXTRACTION_POLICY",
7777
* // scope: "ALL",
7878
* // selectionCriteria: "STRING_VALUE",
7979
* // accountId: "STRING_VALUE",
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { CloudWatchLogsClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudWatchLogsClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { GetLogObjectRequest, GetLogObjectResponse, GetLogObjectResponseFilterSensitiveLog } from "../models/models_0";
10+
import { de_GetLogObjectCommand, se_GetLogObjectCommand } from "../protocols/Aws_json1_1";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link GetLogObjectCommand}.
21+
*/
22+
export interface GetLogObjectCommandInput extends GetLogObjectRequest {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link GetLogObjectCommand}.
27+
*/
28+
export interface GetLogObjectCommandOutput extends GetLogObjectResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Retrieves a large logging object (LLO) and streams it back. This API is used to fetch the content of large portions of log events that have been ingested through the PutOpenTelemetryLogs API.
32+
* When log events contain fields that would cause the total event size to exceed 1MB, CloudWatch Logs automatically processes up to 10 fields, starting with the largest fields. Each field is truncated as needed to keep
33+
* the total event size as close to 1MB as possible. The excess portions are stored as Large Log Objects (LLOs) and these fields are processed separately and LLO reference system fields (in the format <code>@ptr.$[path.to.field]</code>) are
34+
* added. The path in the reference field reflects the original JSON structure where the large field was located. For example, this could be <code>@ptr.$['input']['message']</code>, <code>@ptr.$['AAA']['BBB']['CCC']['DDD']</code>, <code>@ptr.$['AAA']</code>, or any other path matching your log structure.</p>
35+
* @example
36+
* Use a bare-bones client and the command you need to make an API call.
37+
* ```javascript
38+
* import { CloudWatchLogsClient, GetLogObjectCommand } from "@aws-sdk/client-cloudwatch-logs"; // ES Modules import
39+
* // const { CloudWatchLogsClient, GetLogObjectCommand } = require("@aws-sdk/client-cloudwatch-logs"); // CommonJS import
40+
* const client = new CloudWatchLogsClient(config);
41+
* const input = { // GetLogObjectRequest
42+
* unmask: true || false,
43+
* logObjectPointer: "STRING_VALUE", // required
44+
* };
45+
* const command = new GetLogObjectCommand(input);
46+
* const response = await client.send(command);
47+
* // { // GetLogObjectResponse
48+
* // fieldStream: { // GetLogObjectResponseStream Union: only one key present
49+
* // fields: { // FieldsData
50+
* // data: new Uint8Array(),
51+
* // },
52+
* // InternalStreamingException: { // InternalStreamingException
53+
* // message: "STRING_VALUE",
54+
* // },
55+
* // },
56+
* // };
57+
*
58+
* ```
59+
*
60+
* @param GetLogObjectCommandInput - {@link GetLogObjectCommandInput}
61+
* @returns {@link GetLogObjectCommandOutput}
62+
* @see {@link GetLogObjectCommandInput} for command's `input` shape.
63+
* @see {@link GetLogObjectCommandOutput} for command's `response` shape.
64+
* @see {@link CloudWatchLogsClientResolvedConfig | config} for CloudWatchLogsClient's `config` shape.
65+
*
66+
* @throws {@link AccessDeniedException} (client fault)
67+
* <p>You don't have sufficient permissions to perform this action.</p>
68+
*
69+
* @throws {@link InvalidOperationException} (client fault)
70+
* <p>The operation is not valid on the specified resource.</p>
71+
*
72+
* @throws {@link InvalidParameterException} (client fault)
73+
* <p>A parameter is specified incorrectly.</p>
74+
*
75+
* @throws {@link LimitExceededException} (client fault)
76+
* <p>You have reached the maximum number of resources that can be created.</p>
77+
*
78+
* @throws {@link ResourceNotFoundException} (client fault)
79+
* <p>The specified resource does not exist.</p>
80+
*
81+
* @throws {@link CloudWatchLogsServiceException}
82+
* <p>Base exception class for all service exceptions from CloudWatchLogs service.</p>
83+
*
84+
*
85+
* @public
86+
*/
87+
export class GetLogObjectCommand extends $Command
88+
.classBuilder<
89+
GetLogObjectCommandInput,
90+
GetLogObjectCommandOutput,
91+
CloudWatchLogsClientResolvedConfig,
92+
ServiceInputTypes,
93+
ServiceOutputTypes
94+
>()
95+
.ep(commonParams)
96+
.m(function (this: any, Command: any, cs: any, config: CloudWatchLogsClientResolvedConfig, o: any) {
97+
return [
98+
getSerdePlugin(config, this.serialize, this.deserialize),
99+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
100+
];
101+
})
102+
.s("Logs_20140328", "GetLogObject", {
103+
/**
104+
* @internal
105+
*/
106+
eventStream: {
107+
output: true,
108+
},
109+
})
110+
.n("CloudWatchLogsClient", "GetLogObjectCommand")
111+
.f(void 0, GetLogObjectResponseFilterSensitiveLog)
112+
.ser(se_GetLogObjectCommand)
113+
.de(de_GetLogObjectCommand)
114+
.build() {
115+
/** @internal type navigation helper, not in runtime. */
116+
protected declare static __types: {
117+
api: {
118+
input: GetLogObjectRequest;
119+
output: GetLogObjectResponse;
120+
};
121+
sdk: {
122+
input: GetLogObjectCommandInput;
123+
output: GetLogObjectCommandOutput;
124+
};
125+
};
126+
}

clients/client-cloudwatch-logs/src/commands/PutAccountPolicyCommand.ts

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ export interface PutAccountPolicyCommandInput extends PutAccountPolicyRequest {}
2828
export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse, __MetadataBearer {}
2929

3030
/**
31-
* <p>Creates an account-level data protection policy, subscription filter policy, or field
32-
* index policy that applies to all log groups or a subset of log groups in the account.</p>
31+
* <p>Creates an account-level data protection policy, subscription filter policy, field index
32+
* policy, transformer policy, or metric extraction policy that applies to all log groups or a
33+
* subset of log groups in the account.</p>
3334
* <p>To use this operation, you must be signed on with the correct permissions depending on the
3435
* type of policy that you are creating.</p>
3536
* <ul>
@@ -51,6 +52,11 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
5152
* <p>To create a field index policy, you must have the <code>logs:PutIndexPolicy</code> and
5253
* <code>logs:PutAccountPolicy</code> permissions.</p>
5354
* </li>
55+
* <li>
56+
* <p>To create a metric extraction policy, you must have the
57+
* <code>logs:PutMetricExtractionPolicy</code> and
58+
* <code>logs:PutAccountPolicy</code> permissions.</p>
59+
* </li>
5460
* </ul>
5561
* <p>
5662
* <b>Data protection policy</b>
@@ -183,6 +189,57 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
183189
* <p>If you want to create a field index policy for a single log group, you can use <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutIndexPolicy.html">PutIndexPolicy</a> instead of <code>PutAccountPolicy</code>. If you do so, that log
184190
* group will use only that log-group level policy, and will ignore the account-level policy that
185191
* you create with <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutAccountPolicy.html">PutAccountPolicy</a>.</p>
192+
* <p>
193+
* <b>Metric extraction policy</b>
194+
* </p>
195+
* <p>A metric extraction policy controls whether CloudWatch Metrics can be created through the
196+
* Embedded Metrics Format (EMF) for log groups in your account. By default, EMF metric creation
197+
* is enabled for all log groups. You can use metric extraction policies to disable EMF metric
198+
* creation for your entire account or specific log groups.</p>
199+
* <p>When a policy disables EMF metric creation for a log group, log events in the EMF format
200+
* are still ingested, but no CloudWatch Metrics are created from them.</p>
201+
* <important>
202+
* <p>Creating a policy disables metrics for AWS features that use EMF to create metrics, such
203+
* as CloudWatch Container Insights and CloudWatch Application Signals. To prevent turning off
204+
* those features by accident, we recommend that you exclude the underlying log-groups through a
205+
* selection-criteria such as <code>LogGroupNamePrefix NOT IN ["/aws/containerinsights",
206+
* "/aws/ecs/containerinsights", "/aws/application-signals/data"]</code>.</p>
207+
* </important>
208+
* <p>Each account can have either one account-level metric extraction policy that applies to
209+
* all log groups, or up to 5 policies that are each scoped to a subset of log groups with the
210+
* <code>selectionCriteria</code> parameter. The selection criteria supports filtering by <code>LogGroupName</code> and
211+
* <code>LogGroupNamePrefix</code> using the operators <code>IN</code> and <code>NOT IN</code>. You can specify up to 50 values in each
212+
* <code>IN</code> or <code>NOT IN</code> list.</p>
213+
* <p>The selection criteria can be specified in these formats:</p>
214+
* <p>
215+
* <code>LogGroupName IN ["log-group-1", "log-group-2"]</code>
216+
* </p>
217+
* <p>
218+
* <code>LogGroupNamePrefix NOT IN ["/aws/prefix1", "/aws/prefix2"]</code>
219+
* </p>
220+
* <p>If you have multiple account-level metric extraction policies with selection criteria, no
221+
* two of them can have overlapping criteria. For example, if you have one policy with selection
222+
* criteria <code>LogGroupNamePrefix IN ["my-log"]</code>, you can't have another metric extraction policy
223+
* with selection criteria <code>LogGroupNamePrefix IN ["/my-log-prod"]</code> or <code>LogGroupNamePrefix IN
224+
* ["/my-logging"]</code>, as the set of log groups matching these prefixes would be a subset of the log
225+
* groups matching the first policy's prefix, creating an overlap.</p>
226+
* <p>When using <code>NOT IN</code>, only one policy with this operator is allowed per account.</p>
227+
* <p>When combining policies with <code>IN</code> and <code>NOT IN</code> operators, the overlap check ensures that
228+
* policies don't have conflicting effects. Two policies with <code>IN</code> and <code>NOT IN</code> operators do not
229+
* overlap if and only if every value in the <code>IN </code>policy is completely contained within some value
230+
* in the <code>NOT IN</code> policy. For example:</p>
231+
* <ul>
232+
* <li>
233+
* <p>If you have a <code>NOT IN</code> policy for prefix <code>"/aws/lambda"</code>, you can create an <code>IN</code> policy for
234+
* the exact log group name <code>"/aws/lambda/function1"</code> because the set of log groups matching
235+
* <code>"/aws/lambda/function1"</code> is a subset of the log groups matching <code>"/aws/lambda"</code>.</p>
236+
* </li>
237+
* <li>
238+
* <p>If you have a <code>NOT IN</code> policy for prefix <code>"/aws/lambda"</code>, you cannot create an <code>IN</code> policy
239+
* for prefix <code>"/aws"</code> because the set of log groups matching <code>"/aws"</code> is not a subset of the log
240+
* groups matching <code>"/aws/lambda"</code>.</p>
241+
* </li>
242+
* </ul>
186243
* @example
187244
* Use a bare-bones client and the command you need to make an API call.
188245
* ```javascript
@@ -192,7 +249,7 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
192249
* const input = { // PutAccountPolicyRequest
193250
* policyName: "STRING_VALUE", // required
194251
* policyDocument: "STRING_VALUE", // required
195-
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY", // required
252+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY" || "METRIC_EXTRACTION_POLICY", // required
196253
* scope: "ALL",
197254
* selectionCriteria: "STRING_VALUE",
198255
* };
@@ -203,7 +260,7 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
203260
* // policyName: "STRING_VALUE",
204261
* // policyDocument: "STRING_VALUE",
205262
* // lastUpdatedTime: Number("long"),
206-
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY",
263+
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY" || "FIELD_INDEX_POLICY" || "TRANSFORMER_POLICY" || "METRIC_EXTRACTION_POLICY",
207264
* // scope: "ALL",
208265
* // selectionCriteria: "STRING_VALUE",
209266
* // accountId: "STRING_VALUE",

clients/client-cloudwatch-logs/src/commands/UntagLogGroupCommand.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ export interface UntagLogGroupCommandOutput extends __MetadataBearer {}
3434
* </important>
3535
* <p>Removes the specified tags from the specified log group.</p>
3636
* <p>To list the tags for a log group, use <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListTagsForResource.html">ListTagsForResource</a>. To add tags, use <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_TagResource.html">TagResource</a>.</p>
37-
* <p>CloudWatch Logs doesn't support IAM policies that prevent users from assigning specified
38-
* tags to log groups using the <code>aws:Resource/<i>key-name</i>
39-
* </code> or
40-
* <code>aws:TagKeys</code> condition keys. </p>
37+
* <p>When using IAM policies to control tag management for CloudWatch Logs log groups, the
38+
* condition keys <code>aws:Resource/key-name</code> and <code>aws:TagKeys</code> cannot be used to restrict which tags
39+
* users can assign. </p>
4140
*
4241
* @deprecated Please use the generic tagging API UntagResource
4342
* @example

clients/client-cloudwatch-logs/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export * from "./GetIntegrationCommand";
5151
export * from "./GetLogAnomalyDetectorCommand";
5252
export * from "./GetLogEventsCommand";
5353
export * from "./GetLogGroupFieldsCommand";
54+
export * from "./GetLogObjectCommand";
5455
export * from "./GetLogRecordCommand";
5556
export * from "./GetQueryResultsCommand";
5657
export * from "./GetTransformerCommand";

0 commit comments

Comments
 (0)