我正在尝试使用Java(CloudWatch客户端)提取AWS实例指标。我能够提取CPUUtilization,MemoryAvailable等指标,但无法提取DiskSpaceUsed和DiskSpaceAvailable。 我遵循的步骤是:
连接到实例并运行以下命令:
./mon-put-instance-data.pl --disk-path=/dev/xvda1 --disk-space-used
Successfully reported metrics to CloudWatch. Reference Id: 676e3970-d5d4-11e8-82a2-c732e192c2b2
./mon-put-instance-data.pl --disk-path=/dev/xvda1 --disk-space-used
Successfully reported metrics to CloudWatch. Reference Id: 6ad61d23-d5d4-11e8-9fdc-e5974e111635
Java代码如下:
private static GetMetricStatisticsRequest requestCustom(final String instanceId, final String metric) { final long twentyFourHrs = 1000 * 60 * 60 * 24; final int oneHour = 60 * 60; return new GetMetricStatisticsRequest() .withStartTime(new Date(new Date().getTime() - twentyFourHrs)) .withNamespace("System/Linux").withPeriod(oneHour) .withDimensions(new Dimension().withName("InstanceId").withValue(instanceId)) .withMetricName(metric).withStatistics("Average", "Maximum").withEndTime(new Date()); }
输出如下:
{Label: DiskSpaceUsed,Datapoints: []}
{Label: DiskSpaceAvailable,Datapoints: []}
我对MemoryUsed和MemoryAvailable度量遵循的相同过程。我正在获取MemoryUsed和MemoryAvailable的输出,但没有获取DiskSpaceUsed的输出。 怎么了?