本文整理了Java中com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest.withStartTime()
方法的一些代码示例,展示了GetMetricStatisticsRequest.withStartTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GetMetricStatisticsRequest.withStartTime()
方法的具体详情如下:
包路径:com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest
类名称:GetMetricStatisticsRequest
方法名:withStartTime
[英]The time stamp that determines the first data point to return. Start times are evaluated relative to the time that CloudWatch receives the request.
The value specified is inclusive; results include data points with the specified time stamp. The time stamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z).
CloudWatch rounds the specified time stamp as follows:
If you set Period
to 5, 10, or 30, the start time of your request is rounded down to the nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15.
[中]确定要返回的第一个数据点的时间戳。开始时间是相对于CloudWatch收到请求的时间来计算的。
指定的值包括在内;结果包括具有指定时间戳的数据点。时间戳必须采用ISO 8601 UTC格式(例如,2016-10-03T23:00:00Z)。
CloudWatch按如下方式舍入指定的时间戳:
*开始时间不到15天前-四舍五入到最接近的整分钟。例如,12:32:34向下舍入为12:32:00。
*开始时间为15至63天前-四舍五入至最接近的5分钟时钟间隔。例如,12:32:34向下舍入为12:30:00。
*开始时间大于63天前-四舍五入至最接近的1小时时钟间隔。例如,12:32:34向下舍入为12:00:00。
如果将Period
设置为5、10或30,则请求的开始时间将向下舍入到最接近的时间,该时间甚至对应于一分钟的5、10或30秒刻度。例如,如果您在(HH:mm:ss)01:05:23处对前10秒的时间段进行查询,则请求的开始时间将向下舍入,并且您将收到01:05:10到01:05:20之间的数据。如果您在15:07:17查询前5分钟的数据,使用5秒的时间段,您将收到时间戳介于15:02:15和15:07:15之间的数据。
代码示例来源:origin: awslabs/amazon-kinesis-scaling-utils
double sampleMetric = 0D;
req.withStartTime(metricStartTime.toDate()).withEndTime(metricEndTime.toDate());
代码示例来源:origin: tmobile/pacbot
private static GetMetricStatisticsRequest request(
final String funcationValue, int hours) {
final long twentyFourHrs = 1000 * 60 * 60l * hours;
final int oneHour = 60 * 60 * hours;
return new GetMetricStatisticsRequest()
.withStartTime(new Date(new Date().getTime() - twentyFourHrs))
.withNamespace(PacmanRuleConstants.AWS_LAMBDA)
.withPeriod(oneHour)
.withDimensions(
new Dimension().withName("FunctionName").withValue(
funcationValue))
.withMetricName(PacmanRuleConstants.INVOCATIONS)
.withStatistics("Sum").withEndTime(new Date());
}
代码示例来源:origin: tmobile/pacbot
private static GetMetricStatisticsRequest request(
final String funcationValue) {
final int fiveMin = 60 * 60 * 24;
return new GetMetricStatisticsRequest()
.withStartTime(new Date(new Date().getTime() - TWENTYFOURHOURS))
.withNamespace(PacmanRuleConstants.AWS_LAMBDA)
.withPeriod(fiveMin)
.withDimensions(
new Dimension().withName(
PacmanRuleConstants.FUNCTION_NAME).withValue(
funcationValue))
.withMetricName(PacmanRuleConstants.THROTTLES)
.withStatistics(PacmanRuleConstants.SUM)
.withEndTime(new Date());
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
GetMetricStatisticsRequest createMetricStatisticsRequest(
String streamName, Instant countSince, Instant countTo, Minutes period) {
return new GetMetricStatisticsRequest()
.withNamespace(KINESIS_NAMESPACE)
.withMetricName(INCOMING_RECORDS_METRIC)
.withPeriod(period.getMinutes() * PERIOD_GRANULARITY_IN_SECONDS)
.withStartTime(countSince.toDate())
.withEndTime(countTo.toDate())
.withStatistics(Collections.singletonList(SUM_STATISTIC))
.withDimensions(
Collections.singletonList(
new Dimension().withName(STREAM_NAME_DIMENSION).withValue(streamName)));
}
代码示例来源: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;
}
}
内容来源于网络,如有侵权,请联系作者删除!