-
Notifications
You must be signed in to change notification settings - Fork 573
/
GetMetricDataCommand.ts
130 lines (120 loc) · 6.28 KB
/
GetMetricDataCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { CloudWatchClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudWatchClient";
import { GetMetricDataInput, GetMetricDataOutput } from "../models/models_0";
import {
deserializeAws_queryGetMetricDataCommand,
serializeAws_queryGetMetricDataCommand,
} from "../protocols/Aws_query";
export interface GetMetricDataCommandInput extends GetMetricDataInput {}
export interface GetMetricDataCommandOutput extends GetMetricDataOutput, __MetadataBearer {}
/**
* <p>You can use the <code>GetMetricData</code> API to retrieve as many as 500 different
* metrics in a single request, with a total of as many as 100,800 data points. You can also
* optionally perform math expressions on the values of the returned statistics, to create
* new time series that represent new insights into your data. For example, using Lambda
* metrics, you could divide the Errors metric by the Invocations metric to get an error
* rate time series. For more information about metric math expressions, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html#metric-math-syntax">Metric Math Syntax and Functions</a> in the <i>Amazon CloudWatch User
* Guide</i>.</p>
*
* <p>Calls to the <code>GetMetricData</code> API have a different pricing structure than
* calls to <code>GetMetricStatistics</code>. For more information about pricing, see
* <a href="https://aws.amazon.com/cloudwatch/pricing/">Amazon CloudWatch Pricing</a>.</p>
*
* <p>Amazon CloudWatch retains metric data as follows:</p>
* <ul>
* <li>
* <p>Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution
* metrics and are available only for custom metrics that have been defined with a <code>StorageResolution</code> of 1.</p>
* </li>
* <li>
* <p>Data points with a period of 60 seconds (1-minute) are available for 15 days.</p>
* </li>
* <li>
* <p>Data points with a period of 300 seconds (5-minute) are available for 63 days.</p>
* </li>
* <li>
* <p>Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).</p>
* </li>
* </ul>
* <p>Data points that are initially published with a shorter period are aggregated together for long-term storage. For example, if you collect
* data using a period of 1 minute, the data remains available for 15 days with 1-minute resolution. After 15 days, this data is still available,
* but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with
* a resolution of 1 hour.</p>
*
* <p>If you omit <code>Unit</code> in your request, all data that was collected with any unit is returned, along with the corresponding units that were specified
* when the data was reported to CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit specified.
* If you specify a unit that does not match the data collected, the results of the operation are null. CloudWatch does not perform unit conversions.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CloudWatchClient, GetMetricDataCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
* // const { CloudWatchClient, GetMetricDataCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
* const client = new CloudWatchClient(config);
* const command = new GetMetricDataCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetMetricDataCommandInput} for command's `input` shape.
* @see {@link GetMetricDataCommandOutput} for command's `response` shape.
* @see {@link CloudWatchClientResolvedConfig | config} for CloudWatchClient's `config` shape.
*
*/
export class GetMetricDataCommand extends $Command<
GetMetricDataCommandInput,
GetMetricDataCommandOutput,
CloudWatchClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties
constructor(readonly input: GetMetricDataCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: CloudWatchClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetMetricDataCommandInput, GetMetricDataCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "CloudWatchClient";
const commandName = "GetMetricDataCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetMetricDataInput.filterSensitiveLog,
outputFilterSensitiveLog: GetMetricDataOutput.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(input: GetMetricDataCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_queryGetMetricDataCommand(input, context);
}
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetMetricDataCommandOutput> {
return deserializeAws_queryGetMetricDataCommand(output, context);
}
// Start section: command_body_extra
// End section: command_body_extra
}