AWS Cloudwatch stores custom metrics for a duration dependent upon the metric's period:
- Data points with a period of less than 60 seconds are available for 3 hours. These data points are high-resolution custom metrics.
- Data points with a period of 60 seconds (1 minute) are available for 15 days
- Data points with a period of 300 seconds (5 minute) are available for 63 days
- Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months)
from https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html
However, I cannot find out how to set the Period for a given metric using the JS SDK:
// Calling the putMetricData operation
var params = {
MetricData: [ /* required */
{
MetricName: 'STRING_VALUE', /* required */
Counts: [
'NUMBER_VALUE',
/* more items */
],
Dimensions: [
{
Name: 'STRING_VALUE', /* required */
Value: 'STRING_VALUE' /* required */
},
/* more items */
],
StatisticValues: {
Maximum: 'NUMBER_VALUE', /* required */
Minimum: 'NUMBER_VALUE', /* required */
SampleCount: 'NUMBER_VALUE', /* required */
Sum: 'NUMBER_VALUE' /* required */
},
StorageResolution: 'NUMBER_VALUE',
Timestamp: new Date || 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)' || 123456789,
Unit: Seconds | Microseconds | Milliseconds | Bytes | Kilobytes | Megabytes | Gigabytes | Terabytes | Bits | Kilobits | Megabits | Gigabits | Terabits | Percent | Count | Bytes/Second | Kilobytes/Second | Megabytes/Second | Gigabytes/Second | Terabytes/Second | Bits/Second | Kilobits/Second | Megabits/Second | Gigabits/Second | Terabits/Second | Count/Second | None,
Value: 'NUMBER_VALUE',
Values: [
'NUMBER_VALUE',
/* more items */
]
},
/* more items */
],
Namespace: 'STRING_VALUE' /* required */
};
cloudwatch.putMetricData(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#putMetricData-property
There's references to period
elsewhere in the docs, but not directly relating to MetricData.
Is a "Data point" different from "Metric Data"?
How do I control how long metric data will survive?
Edit, more information:
CloudWatch metrics are rolled up over time; resolution effectively decreases as the metrics age. Here’s the schedule:
1 second metrics are available for 3 hours. 60 second metrics are available for 15 days. 5 minute metrics are available for 63 days. 1 hour metrics are available for 455 days (15 months).
When you call GetMetricStatistics you can specify a period of 1, 5, 10, 30 or any multiple of 60 seconds for high-resolution metrics. You can specify any multiple of 60 seconds for standard metrics. from https://aws.amazon.com/blogs/aws/new-high-resolution-custom-metrics-and-alarms-for-amazon-cloudwatch/ Based on this post, it sounds like data points will automatically average metrics as they age. In that case does this mean that data points are only entirely deleted once they fully expire at 15 months?