Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.cloudwatch.model;
 
 
Container for the parameters to the GetMetricStatistics operation.

Gets statistics for the specified metric.

NOTE: The maximum number of data points returned from a single GetMetricStatistics request is 1,440. If a request is made that generates more than 1,440 data points, Amazon CloudWatch returns an error. In such a case, alter the request by narrowing the specified time range or increasing the specified period. Alternatively, make multiple requests across adjacent time ranges.

Amazon CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request statistics with a one-minute granularity, Amazon CloudWatch aggregates data points with time stamps that fall within the same one-minute period. In such a case, the data points queried can greatly outnumber the data points returned.

NOTE: The maximum number of data points that can be queried is 50,850; whereas the maximum number of data points returned is 1,440.

The following examples show various statistics allowed by the data point query maximum of 50,850 when you call GetMetricStatistics on Amazon EC2 instances with detailed (one-minute) monitoring enabled:

  • Statistics for up to 400 instances for a span of one hour
  • Statistics for up to 35 instances over a span of 24 hours
  • Statistics for up to 2 instances over a span of 2 weeks

 
 public class GetMetricStatisticsRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
The namespace of the metric.

Constraints:
Length: 1 - 255
Pattern: [^:].*

 
     private String namespace;

    
The name of the metric.

Constraints:
Length: 1 - 255

 
     private String metricName;

    
A list of dimensions describing qualities of the metric.

Constraints:
Length: 0 - 10

 
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>
 
     private java.util.Date startTime;

    
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
    private java.util.Date endTime;

    
The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.

Constraints:
Range: 60 -

    private Integer period;

    
The metric statistics to return.

Constraints:
Length: 1 - 5

The unit for the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

    private String unit;

    
The namespace of the metric.

Constraints:
Length: 1 - 255
Pattern: [^:].*

Returns:
The namespace of the metric.
    public String getNamespace() {
        return ;
    }
    
    
The namespace of the metric.

Constraints:
Length: 1 - 255
Pattern: [^:].*

Parameters:
namespace The namespace of the metric.
    public void setNamespace(String namespace) {
        this. = namespace;
    }
    
    
The namespace of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 255
Pattern: [^:].*

Parameters:
namespace The namespace of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withNamespace(String namespace) {
        this. = namespace;
        return this;
    }

    
The name of the metric.

Constraints:
Length: 1 - 255

Returns:
The name of the metric.
    public String getMetricName() {
        return ;
    }
    
    
The name of the metric.

Constraints:
Length: 1 - 255

Parameters:
metricName The name of the metric.
    public void setMetricName(String metricName) {
        this. = metricName;
    }
    
    
The name of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 255

Parameters:
metricName The name of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withMetricName(String metricName) {
        this. = metricName;
        return this;
    }

    
A list of dimensions describing qualities of the metric.

Constraints:
Length: 0 - 10

Returns:
A list of dimensions describing qualities of the metric.
    public java.util.List<DimensiongetDimensions() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Dimension>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
A list of dimensions describing qualities of the metric.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions describing qualities of the metric.
    public void setDimensions(java.util.Collection<Dimensiondimensions) {
        if (dimensions == null) {
            this. = null;
            return;
        }
        dimensionsCopy.addAll(dimensions);
        this. = dimensionsCopy;
    }
    
    
A list of dimensions describing qualities of the metric.

NOTE: This method appends the values to the existing list (if any). Use setDimensions(java.util.Collection) or withDimensions(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions describing qualities of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withDimensions(Dimension... dimensions) {
        if (getDimensions() == nullsetDimensions(new java.util.ArrayList<Dimension>(dimensions.length));
        for (Dimension value : dimensions) {
            getDimensions().add(value);
        }
        return this;
    }
    
    
A list of dimensions describing qualities of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions describing qualities of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (dimensions == null) {
            this. = null;
        } else {
            dimensionsCopy.addAll(dimensions);
            this. = dimensionsCopy;
        }
        return this;
    }

    
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>

Returns:
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>
    public java.util.Date getStartTime() {
        return ;
    }
    
    
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>

Parameters:
startTime The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>
    public void setStartTime(java.util.Date startTime) {
        this. = startTime;
    }
    
    
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>

Returns a reference to this object so that method calls can be chained together.

Parameters:
startTime The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. <note> The specified start time is rounded down to the nearest value. Datapoints are returned for start times up to two weeks in the past. Specified start times that are more than two weeks in the past will not return datapoints for metrics that are older than two weeks. </note>
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withStartTime(java.util.Date startTime) {
        this. = startTime;
        return this;
    }

    
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.

Returns:
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
    public java.util.Date getEndTime() {
        return ;
    }
    
    
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.

Parameters:
endTime The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
    public void setEndTime(java.util.Date endTime) {
        this. = endTime;
    }
    
    
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.

Returns a reference to this object so that method calls can be chained together.

Parameters:
endTime The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
Returns:
A reference to this updated object so that method calls can be chained together.
        this. = endTime;
        return this;
    }

    
The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.

Constraints:
Range: 60 -

Returns:
The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
    public Integer getPeriod() {
        return ;
    }
    
    
The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.

Constraints:
Range: 60 -

Parameters:
period The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
    public void setPeriod(Integer period) {
        this. = period;
    }
    
    
The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Range: 60 -

Parameters:
period The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withPeriod(Integer period) {
        this. = period;
        return this;
    }

    
The metric statistics to return.

Constraints:
Length: 1 - 5

Returns:
The metric statistics to return.
    public java.util.List<StringgetStatistics() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
The metric statistics to return.

Constraints:
Length: 1 - 5

Parameters:
statistics The metric statistics to return.
    public void setStatistics(java.util.Collection<Stringstatistics) {
        if (statistics == null) {
            this. = null;
            return;
        }
        statisticsCopy.addAll(statistics);
        this. = statisticsCopy;
    }
    
    
The metric statistics to return.

NOTE: This method appends the values to the existing list (if any). Use setStatistics(java.util.Collection) or withStatistics(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 5

Parameters:
statistics The metric statistics to return.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withStatistics(String... statistics) {
        if (getStatistics() == nullsetStatistics(new java.util.ArrayList<String>(statistics.length));
        for (String value : statistics) {
            getStatistics().add(value);
        }
        return this;
    }
    
    
The metric statistics to return.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 5

Parameters:
statistics The metric statistics to return.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (statistics == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringstatisticsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(statistics.size());
            statisticsCopy.addAll(statistics);
            this. = statisticsCopy;
        }
        return this;
    }

    
The metric statistics to return.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 5

Parameters:
statistics The metric statistics to return.
Returns:
A reference to this updated object so that method calls can be chained together.
    public GetMetricStatisticsRequest withStatistics(Statistic... statistics) {
        java.util.ArrayList<StringstatisticsCopy = new java.util.ArrayList<String>(statistics.length);
        for (Statistic member : statistics) {
            statisticsCopy.add(member.toString());
        }
        if (getStatistics() == null) {
            setStatistics(statisticsCopy);
        } else {
            getStatistics().addAll(statisticsCopy);
        }
        return this;
    }

    
The unit for the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Returns:
The unit for the metric.
See also:
StandardUnit
    public String getUnit() {
        return ;
    }
    
    
The unit for the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit for the metric.
See also:
StandardUnit
    public void setUnit(String unit) {
        this. = unit;
    }
    
    
The unit for the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit for the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
StandardUnit
    public GetMetricStatisticsRequest withUnit(String unit) {
        this. = unit;
        return this;
    }

    
The unit for the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit for the metric.
See also:
StandardUnit
    public void setUnit(StandardUnit unit) {
        this. = unit.toString();
    }
    
    
The unit for the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit for the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
StandardUnit
        this. = unit.toString();
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getNamespace() != nullsb.append("Namespace: " + getNamespace() + ",");
        if (getMetricName() != nullsb.append("MetricName: " + getMetricName() + ",");
        if (getDimensions() != nullsb.append("Dimensions: " + getDimensions() + ",");
        if (getStartTime() != nullsb.append("StartTime: " + getStartTime() + ",");
        if (getEndTime() != nullsb.append("EndTime: " + getEndTime() + ",");
        if (getPeriod() != nullsb.append("Period: " + getPeriod() + ",");
        if (getStatistics() != nullsb.append("Statistics: " + getStatistics() + ",");
        if (getUnit() != nullsb.append("Unit: " + getUnit() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getNamespace() == null) ? 0 : getNamespace().hashCode()); 
        hashCode = prime * hashCode + ((getMetricName() == null) ? 0 : getMetricName().hashCode()); 
        hashCode = prime * hashCode + ((getDimensions() == null) ? 0 : getDimensions().hashCode()); 
        hashCode = prime * hashCode + ((getStartTime() == null) ? 0 : getStartTime().hashCode()); 
        hashCode = prime * hashCode + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); 
        hashCode = prime * hashCode + ((getPeriod() == null) ? 0 : getPeriod().hashCode()); 
        hashCode = prime * hashCode + ((getStatistics() == null) ? 0 : getStatistics().hashCode()); 
        hashCode = prime * hashCode + ((getUnit() == null) ? 0 : getUnit().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof GetMetricStatisticsRequest == falsereturn false;
        
        if (other.getNamespace() == null ^ this.getNamespace() == nullreturn false;
        if (other.getNamespace() != null && other.getNamespace().equals(this.getNamespace()) == falsereturn false
        if (other.getMetricName() == null ^ this.getMetricName() == nullreturn false;
        if (other.getMetricName() != null && other.getMetricName().equals(this.getMetricName()) == falsereturn false
        if (other.getDimensions() == null ^ this.getDimensions() == nullreturn false;
        if (other.getDimensions() != null && other.getDimensions().equals(this.getDimensions()) == falsereturn false
        if (other.getStartTime() == null ^ this.getStartTime() == nullreturn false;
        if (other.getStartTime() != null && other.getStartTime().equals(this.getStartTime()) == falsereturn false
        if (other.getEndTime() == null ^ this.getEndTime() == nullreturn false;
        if (other.getEndTime() != null && other.getEndTime().equals(this.getEndTime()) == falsereturn false
        if (other.getPeriod() == null ^ this.getPeriod() == nullreturn false;
        if (other.getPeriod() != null && other.getPeriod().equals(this.getPeriod()) == falsereturn false
        if (other.getStatistics() == null ^ this.getStatistics() == nullreturn false;
        if (other.getStatistics() != null && other.getStatistics().equals(this.getStatistics()) == falsereturn false
        if (other.getUnit() == null ^ this.getUnit() == nullreturn false;
        if (other.getUnit() != null && other.getUnit().equals(this.getUnit()) == falsereturn false
        return true;
    }
    
    @Override
    public GetMetricStatisticsRequest clone() {
        
            return (GetMetricStatisticsRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X