AWS CloudWatch GetMetricStatistics returns 0 个数据点
AWS CloudWatch GetMetricStatistics returns 0 datapoints
我的目标是从特定实例中提取一些指标,但似乎每次我设置请求时,响应总是 return 0 个数据点。
我正在这样设置请求
public object GetMetric(string metricName, string instanceId)
{
var dimension = new Dimension
{
Name = "InstanceId",
Value = instanceId
};
var getMetricRequest = new GetMetricStatisticsRequest
{
Dimensions = new List<Dimension>() { dimension },
EndTime = DateTime.Today,
MetricName = metricName,
Namespace = "AWS/EC2",
Period = (int)TimeSpan.FromDays(1).TotalSeconds,
StartTime = DateTime.Today.Subtract(TimeSpan.FromDays(7)),
Statistics = new List<string> { "Maximum" },
Unit = StandardUnit.Percent
};
var getMetricResponse = client2.GetMetricStatistics(getMetricRequest);
return getMetricResponse;
}
其中 instanceId
设置为我的相关实例 ID,metricName
设置为 CPUUtilization。我是 运行 实例上的一个 powershell 脚本,用于生成小的 cpu 尖峰,所以我知道数据在那里。
根据文档,请求中的属性有效
http://docs.aws.amazon.com/sdkfornet/v3/apidocs/Index.html
我是不是遗漏了什么明显的东西?我不明白我是如何收不到任何数据的。我仔细检查了参数,它们也是正确的。
编辑:
我正在获取数据点。我想将统计数据发送到 Cloud Watch 只需要一段时间。
我的目标是从特定实例中提取一些指标,但似乎每次我设置请求时,响应总是 return 0 个数据点。
我正在这样设置请求
public object GetMetric(string metricName, string instanceId)
{
var dimension = new Dimension
{
Name = "InstanceId",
Value = instanceId
};
var getMetricRequest = new GetMetricStatisticsRequest
{
Dimensions = new List<Dimension>() { dimension },
EndTime = DateTime.Today,
MetricName = metricName,
Namespace = "AWS/EC2",
Period = (int)TimeSpan.FromDays(1).TotalSeconds,
StartTime = DateTime.Today.Subtract(TimeSpan.FromDays(7)),
Statistics = new List<string> { "Maximum" },
Unit = StandardUnit.Percent
};
var getMetricResponse = client2.GetMetricStatistics(getMetricRequest);
return getMetricResponse;
}
其中 instanceId
设置为我的相关实例 ID,metricName
设置为 CPUUtilization。我是 运行 实例上的一个 powershell 脚本,用于生成小的 cpu 尖峰,所以我知道数据在那里。
根据文档,请求中的属性有效 http://docs.aws.amazon.com/sdkfornet/v3/apidocs/Index.html
我是不是遗漏了什么明显的东西?我不明白我是如何收不到任何数据的。我仔细检查了参数,它们也是正确的。
编辑:
我正在获取数据点。我想将统计数据发送到 Cloud Watch 只需要一段时间。