控制自定义指标在 AWS Cloudwatch 中的存储时间
Control how long Custom Metrics are stored in AWS Cloudwatch
AWS Cloudwatch 存储自定义指标的持续时间取决于指标的周期:
- 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)
来自 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html
但是,我无法找到如何使用 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
文档中的其他地方提到了 period
,但与 MetricData 没有直接关系。
"Data point" 与 "Metric Data" 不同吗?
如何控制指标数据的存活时间?
编辑,更多信息:
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?
您无法控制数据的存储时间,您可以控制发布数据的频率。
例如,如果您每分钟发布一次数据,则可以在 15 天内以 1 分钟分辨率绘制图表。当数据老化超过 15 天时,您只能以 5 分钟分辨率绘制它。同样1小时。
异常是分辨率低于 1 分钟的数据。在这种情况下,您需要发布所需的解决方案。如果你每秒发布一次数据并且你想以 1 秒的分辨率绘制它,你可以设置 StorageResolution=1
.
Period 用于绘制数据图表或通过 API 检索数据。例如,即使您每分钟发布一次数据,您也可能想要绘制 1 小时或 1 天的数据聚合图。在这种情况下,您可以将周期设置为 3600 或 86400。
AWS Cloudwatch 存储自定义指标的持续时间取决于指标的周期:
- 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)
来自 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html
但是,我无法找到如何使用 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
文档中的其他地方提到了 period
,但与 MetricData 没有直接关系。
"Data point" 与 "Metric Data" 不同吗?
如何控制指标数据的存活时间?
编辑,更多信息:
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?
您无法控制数据的存储时间,您可以控制发布数据的频率。
例如,如果您每分钟发布一次数据,则可以在 15 天内以 1 分钟分辨率绘制图表。当数据老化超过 15 天时,您只能以 5 分钟分辨率绘制它。同样1小时。
异常是分辨率低于 1 分钟的数据。在这种情况下,您需要发布所需的解决方案。如果你每秒发布一次数据并且你想以 1 秒的分辨率绘制它,你可以设置 StorageResolution=1
.
Period 用于绘制数据图表或通过 API 检索数据。例如,即使您每分钟发布一次数据,您也可能想要绘制 1 小时或 1 天的数据聚合图。在这种情况下,您可以将周期设置为 3600 或 86400。