我有一些从 cloudwatch api 重试的数据。具体来说,我用过listMetrics
. 我从这个电话中得到的数据是:
{Metrics: [{Namespace: Testing, MetricName: hello123, Dimensions: [{Name: name, Value: 1425, }], }, {Namespace: Metric from grails, MetricName: hello123, Dimensions: [{Name: name, Value: 1068, }], },
正如我所料,这是正确的数据。我需要一种只返回value
字段的方法。不是其他的东西。在java中有没有办法做到这一点?
编辑:
我用于创建指标的代码是:
MetricDatum metricDatum = new MetricDatum().withMetricName("hello123").withValue(80.0)
Dimension tableDimension = new Dimension()
tableDimension.withName("hello123")
tableDimension.withValue("somvalues")
Collection<Dimension> values = new ArrayList<Dimension>();
values << tableDimension
metricDatum.withDimensions(values)
cloudWatch.putMetricData(new PutMetricDataRequest().withNamespace("Metric from grails").withMetricData(metricDatum))
为了列出维度值,我使用:
DimensionFilter tableDimension2 = new DimensionFilter()
tableDimension2.withName("hello123")
Collection<DimensionFilter> values2 = new ArrayList<DimensionFilter>();
values2 << tableDimension2
query = new ListMetricsRequest().withNamespace("Testing").withDimensions(values2)
def result = amazonWebService.cloudWatch.listMetrics(query)
我在哪里犯错误?
提前致谢。