本文整理了Java中com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest.withUnit()
方法的一些代码示例,展示了GetMetricStatisticsRequest.withUnit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GetMetricStatisticsRequest.withUnit()
方法的具体详情如下:
包路径:com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest
类名称:GetMetricStatisticsRequest
方法名:withUnit
[英]The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in all units being returned. If you specify only a unit that the metric does not report, the results of the call are null.
[中]给定度量的单位。指标可以以多个单位报告。不提供单元会导致返回所有单元。如果只指定度量不报告的单位,则调用结果为空。
代码示例来源:origin: aws/aws-sdk-java
/**
* <p>
* The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in all units
* being returned. If you specify only a unit that the metric does not report, the results of the call are null.
* </p>
*
* @param unit
* The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in
* all units being returned. If you specify only a unit that the metric does not report, the results of the
* call are null.
* @see StandardUnit
*/
public void setUnit(StandardUnit unit) {
withUnit(unit);
}
代码示例来源:origin: classmethod/gradle-aws-plugin
public GetMetricStatisticsResult getMetricStatistics(String metricName, String namespace, String statistics,
String extendedStatistics, String unit) throws AmazonServiceException {
AwsCloudWatchPluginExtension ext = getProject().getExtensions().getByType(AwsCloudWatchPluginExtension.class);
AmazonCloudWatch cw = ext.getClient();
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
.withMetricName(metricName)
.withNamespace(namespace)
.withStatistics(statistics)
.withExtendedStatistics(extendedStatistics)
.withUnit(unit)
.withEndTime(getEndTime())
.withStartTime(getStartTime())
.withPeriod(getPeriod());
if (getDimensions() != null) {
request.withDimensions(getDimensions().entrySet().stream()
.map(it -> new Dimension()
.withName(it.getKey().toString())
.withValue(it.getValue()))
.collect(Collectors.toList()));
}
GetMetricStatisticsResult response = cw.getMetricStatistics(request);
for (Datapoint metric : response.getDatapoints()) {
getLogger().debug("Retrieved metric %s", metric.getAverage());
}
return response;
}
代码示例来源:origin: yegor256/s3auth
@Override
@Cacheable(lifetime = Tv.THIRTY, unit = TimeUnit.MINUTES)
public long bytesTransferred() {
final Date now = new Date();
final List<Datapoint> datapoints =
DefaultHost.this.cloudwatch.get().getMetricStatistics(
new GetMetricStatisticsRequest()
.withMetricName("BytesTransferred")
.withNamespace("S3Auth")
.withStatistics("Sum")
.withDimensions(
new Dimension()
.withName("Bucket")
.withValue(this.bucket)
)
.withUnit(StandardUnit.Bytes)
.withPeriod((int) TimeUnit.DAYS.toSeconds(Tv.SEVEN))
.withStartTime(DateUtils.addWeeks(now, -1))
.withEndTime(now)
).getDatapoints();
long sum = 0L;
for (final Datapoint datapoint : datapoints) {
sum += datapoint.getSum();
}
return sum;
}
}
内容来源于网络,如有侵权,请联系作者删除!