Class CloudWatchMetricStreamDefinition
- java.lang.Object
-
- com.elastisys.autoscaler.metricstreamers.cloudwatch.config.CloudWatchMetricStreamDefinition
-
public class CloudWatchMetricStreamDefinition extends java.lang.ObjectRepresents a metric stream definition published for subscription by aCloudWatchMetricStreamer.CloudWatchMetricStreamDefinitions are configured through aCloudWatchMetricStreamerConfig. For more details on the meaning of the different parameters, refer to the CloudWatch concepts introduction, the Amazon CloudWatch API specification and the CloudWatch Metrics, Namespaces, and Dimensions Reference.
-
-
Field Summary
Fields Modifier and Type Field Description static longCLOUDWATCH_MAX_DATA_POINTSThe maximum number of data points that can be requested in a single call to the CloudWatch API.static java.lang.BooleanDEFAULT_RATE_CONVERSION
-
Constructor Summary
Constructors Constructor Description CloudWatchMetricStreamDefinition(java.lang.String id, java.lang.String namespace, java.lang.String metric, CloudWatchStatistic statistic, com.elastisys.scale.commons.json.types.TimeInterval period, java.lang.Boolean convertToRate, java.util.Map<java.lang.String,java.lang.String> dimensions, com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime, com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)Constructs a newCloudWatchMetricStreamDefinition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)com.elastisys.scale.commons.json.types.TimeIntervalgetDataSettlingTime()Returns the minimum age of requested data points.java.util.Map<java.lang.String,java.lang.String>getDimensions()Returns the dimensions (key-value pairs) used to narrow down the set of streamed metric values.java.lang.StringgetId()Returns the id of the metric stream.java.lang.StringgetMetric()Returns the CloudWatch metric that the metric stream retrievesMetricValues for.java.lang.StringgetNamespace()Returns the Amazon CloudWatch namespace of the metric to fetch.com.elastisys.scale.commons.json.types.TimeIntervalgetPeriod()Returns Specifies the time period over which to apply the statistic and, hence, the spacing between data points in the aggregated data.com.elastisys.scale.commons.json.types.TimeIntervalgetQueryChunkSize()The maximum time period that a single query will attempt to fetch in a single call.CloudWatchStatisticgetStatistic()Returns the aggregation method to apply to the set of metric values.inthashCode()booleanisConvertToRate()Whentruethe stream will feed the change rate of the metric rather than the absolute values of the metric.java.lang.StringtoString()voidvalidate()Validates that thisCloudWatchMetricStreamDefinitioncontains sufficient information to allow a valid AWS CloudWatch query to be built.CloudWatchMetricStreamDefinitionwithPeriod(com.elastisys.scale.commons.json.types.TimeInterval period)Creates a field-by-field copy of this object with the period field substituted in the returned clone.CloudWatchMetricStreamDefinitionwithStatistic(CloudWatchStatistic statistic)Creates a field-by-field copy of this object with the statistic field substituted in the returned clone.
-
-
-
Field Detail
-
CLOUDWATCH_MAX_DATA_POINTS
public static final long CLOUDWATCH_MAX_DATA_POINTS
The maximum number of data points that can be requested in a single call to the CloudWatch API.- See Also:
- Constant Field Values
-
DEFAULT_RATE_CONVERSION
public static final java.lang.Boolean DEFAULT_RATE_CONVERSION
-
-
Constructor Detail
-
CloudWatchMetricStreamDefinition
public CloudWatchMetricStreamDefinition(java.lang.String id, java.lang.String namespace, java.lang.String metric, CloudWatchStatistic statistic, com.elastisys.scale.commons.json.types.TimeInterval period, java.lang.Boolean convertToRate, java.util.Map<java.lang.String,java.lang.String> dimensions, com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime, com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)Constructs a newCloudWatchMetricStreamDefinition. See the CloudWatch concepts for an explanation of the parameters.- Parameters:
id- The id of the metric stream. This is the id that will be used by clients wishing to subscribe toMetricValues for this metric stream. Required.namespace- The Amazon CloudWatch namespace of the metric to fetch. Required.metric- The CloudWatch metric that the metric stream retrievesMetricValues for. Required.statistic- The aggregation method to apply to the set of metric values. Can be any of "Sum", "Average", "Minimum", "Maximum" and "SampleCount". Required.period- Specifies the time period over which to apply the statistic and, hence, the spacing between data points in the aggregated data. Must be at least60seconds and must be a multiple of60. Required.convertToRate- Whentruethe stream will feed the change rate of the metric rather than the absolute values of the metric.dimensions- The dimensions (key-value pairs) used to narrow down the set of streamed metric values. Only metric values matching the specified dimensions will be returned. As an example, for EC2 instance metrics (namespace @code ),InstanceIdcan be used to only return values for a certain instance andAutoScalingGroupNameto narrow down queries to only ask for metrics from a certain Auto Scaling Group. May benull.dataSettlingTime- The minimum age of requested data points. TheMetricStreamerwill never request values newer than this from CloudWatch. As such, this value can be regarded as the expected "settling time" of new data points. When requesting aggregate metric data points from CloudWatch that are recent, there is always a risk of seeing partial/incomplete results before metric values from all instances have been registered. Typically, it takes a couple of minutes for all instances to report their values to CloudWatch. May benull. Default is to use no data settling time.queryChunkSize- The maximum time period that a single query will attempt to fetch in a single call. A query with a longer time interval will be run incrementally, each fetching a sub-interval of this duration. This type of incremental retrieval of largeQueryResultSets limits the amount of (memory) resources involved in processing large queries. May benull. Default:#MAX_QUERY_CHUNK_SIZE
-
-
Method Detail
-
getId
public java.lang.String getId()
Returns the id of the metric stream. This is the id that will be used by clients wishing to subscribe toMetricValues for this metric stream.- Returns:
-
getNamespace
public java.lang.String getNamespace()
Returns the Amazon CloudWatch namespace of the metric to fetch.- Returns:
-
getMetric
public java.lang.String getMetric()
Returns the CloudWatch metric that the metric stream retrievesMetricValues for.- Returns:
-
getDimensions
public java.util.Map<java.lang.String,java.lang.String> getDimensions()
Returns the dimensions (key-value pairs) used to narrow down the set of streamed metric values. Only metric values matching the specified dimensions will be returned. As an example, for EC2 instance metrics (namespace @code ),InstanceIdcan be used to only return values for a certain instance andAutoScalingGroupNameto narrow down queries to only ask for metrics from a certain Auto Scaling Group.- Returns:
-
getStatistic
public CloudWatchStatistic getStatistic()
Returns the aggregation method to apply to the set of metric values. Can be any of "Sum", "Average", "Minimum", "Maximum" and "SampleCount".- Returns:
-
getPeriod
public com.elastisys.scale.commons.json.types.TimeInterval getPeriod()
Returns Specifies the time period over which to apply the statistic and, hence, the spacing between data points in the aggregated data. Must be at least60seconds and must be a multiple of60.- Returns:
-
isConvertToRate
public boolean isConvertToRate()
Whentruethe stream will feed the change rate of the metric rather than the absolute values of the metric.- Returns:
-
getDataSettlingTime
public com.elastisys.scale.commons.json.types.TimeInterval getDataSettlingTime()
Returns the minimum age of requested data points. TheMetricStreamerwill never request values newer than this from CloudWatch. As such, this value can be regarded as the expected "settling time" of new data points. When requesting aggregate metric data points from CloudWatch that are recent, there is always a risk of seeing partial/incomplete results before metric values from all instances have been registered. Typically, it takes a couple of minutes for all instances to report their values to CloudWatch.- Returns:
-
getQueryChunkSize
public com.elastisys.scale.commons.json.types.TimeInterval getQueryChunkSize()
The maximum time period that a single query will attempt to fetch in a single call. A query with a longer time interval will be run incrementally, each fetching a sub-interval of this duration. This type of incremental retrieval of largeQueryResultSets limits the amount of (memory) resources involved in processing large queries.- Returns:
-
validate
public void validate() throws java.lang.IllegalArgumentExceptionValidates that thisCloudWatchMetricStreamDefinitioncontains sufficient information to allow a valid AWS CloudWatch query to be built. If it does, the method will just return. If it is found to be invalid, aIllegalArgumentExceptionis thrown.- Throws:
java.lang.IllegalArgumentException- If thisCloudWatchMetricStreamDefinitionis invalid.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withPeriod
public CloudWatchMetricStreamDefinition withPeriod(com.elastisys.scale.commons.json.types.TimeInterval period)
Creates a field-by-field copy of this object with the period field substituted in the returned clone.- Parameters:
period-- Returns:
-
withStatistic
public CloudWatchMetricStreamDefinition withStatistic(CloudWatchStatistic statistic)
Creates a field-by-field copy of this object with the statistic field substituted in the returned clone.- Parameters:
statistic-- Returns:
-
-