【问题标题】:Get all performance metrics of EC2 instance in one call to cloudwatch一次调用 cloudwatch 即可获取 EC2 实例的所有性能指标
【发布时间】:2016-07-29 11:17:49
【问题描述】:

如果我想获得性能指标,比如 EC2 实例的CPUUtilization,我将获得这样的数据:

        GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
        ArrayList<String> stats = new ArrayList<String>();
        stats.add("Average");
        request.setStartTime(startTime);
        request.setEndTime(endTime);
        request.setPeriod(60*6);
        request.setMetricName("CPUUtilization");
        request.setNamespace("AWS/EC2");
        request.setStatistics(stats);
        request.withDimensions(new Dimension().withName("InstanceId").withValue(instanceId));
        GetMetricStatisticsResult getMetricStatisticsResult = cloudService.getMetricStatistics(request);
        java.util.List<Datapoint> datapointsList = getMetricStatisticsResult.getDatapoints();

AFAIK,GetMetricStatistics API 仅返回单个指标的性能。如果我想获得所有性能指标,如CPUUtilization, NetworkIn, NetworkOut, DiskReadOps, DiskWriteOps 等,我需要向 cloudwatch 发出多个请求,以便一次获得每个性能指标。

是否已经有任何方法可以在对 cloudwatch 的 1 个请求中检索所有性能指标?

【问题讨论】:

标签: amazon-web-services amazon-ec2 amazon-cloudwatch


【解决方案1】:

自 2018 年 4 月以来,您可以在单个请求中检索多达 100 个不同的指标,总共可以检索多达 100,800 个数据点。

GetMetricData API reference

【讨论】:

    猜你喜欢
    • 2013-05-18
    • 2013-05-12
    • 2023-02-12
    • 1970-01-01
    • 2017-08-19
    • 2013-04-29
    • 2021-05-29
    • 1970-01-01
    • 2022-11-29
    相关资源
    最近更新 更多