public class CloudWatchReporter
extends com.codahale.metrics.ScheduledReporter
One dimension is always included with the dimension name defined in Constants.DEF_DIM_NAME_TYPE. This corresponds
to a type of metric submissions to CloudWatch.
Refer to [README.md](https://github.com/blacklocus/metrics-cloudwatch/blob/master/README.md) for documentation on metric submission types.
CloudWatch does not aggregate over dimensionChain on custom metrics, see http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/cloudwatch_concepts.html#Dimension To achieve similar convenience, we can submit metrics in duplicate, once for each tuple of attributes against which we would aggregate metrics.
Refer to [README.md](https://github.com/blacklocus/metrics-cloudwatch/blob/master/README.md) for documentation on the name-encoded syntax of dimensions and permutable components.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEF_DIM_VAL_COUNTER_COUNT
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_COUNTER_COUNT. The default value will change from
"counterSum" to |
static java.lang.String |
DEF_DIM_VAL_HISTO_SAMPLES
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_HISTO_SAMPLES. The default value will change from
"histogramCount" to |
static java.lang.String |
DEF_DIM_VAL_HISTO_STATS
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_HISTO_STATS. The default value will change from
"histogramSet" to |
static java.lang.String |
DEF_DIM_VAL_METER_COUNT
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_METER_COUNT. The default value will change from
"meterSum" to |
static java.lang.String |
DEF_DIM_VAL_TIMER_SAMPLES
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_TIMER_SAMPLES. The default value will change from
"timerCount" to |
static java.lang.String |
DEF_DIM_VAL_TIMER_STATS
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_VAL_TIMER_STATS. The default value will change from
"timerSet" to |
static java.lang.String |
METRIC_TYPE_DIMENSION
Deprecated.
maintained for backwards compatibility. Will eventually be replaced by
Constants.DEF_DIM_NAME_TYPE. The default value will change from
"type" to |
static java.lang.String |
NAME_DIMENSION_SEPARATOR
Deprecated.
maintained for backwards compatibility. Moved to
Constants.NAME_DIMENSION_SEPARATOR |
static java.lang.String |
NAME_PERMUTE_MARKER
Deprecated.
maintained for backwards compatibility. Moved to
Constants.NAME_PERMUTE_MARKER |
static java.lang.String |
NAME_TOKEN_DELIMITER
Deprecated.
maintained for backwards compatibility. Moved to
Constants.NAME_TOKEN_DELIMITER |
static java.lang.String |
NAME_TOKEN_DELIMITER_RGX
Deprecated.
maintained for backwards compatibility. Moved to
Constants.NAME_TOKEN_DELIMITER_RGX |
static java.lang.String |
VALID_DIMENSION_PART_RGX
Deprecated.
maintained for backwards compatibility. Moved to
Constants.VALID_DIMENSION_PART_RGX |
static java.lang.String |
VALID_NAME_TOKEN_RGX
Deprecated.
maintained for backwards compatibility. Moved to
Constants.VALID_NAME_TOKEN_RGX |
| Constructor and Description |
|---|
CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
Creates a new
ScheduledReporter instance. |
CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
java.lang.String metricNamespace,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
Creates a new
ScheduledReporter instance. |
CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
java.lang.String metricNamespace,
com.codahale.metrics.MetricFilter metricFilter,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
Creates a new
ScheduledReporter instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
report(java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> gauges,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> counters,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> histograms,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> meters,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> timers) |
CloudWatchReporter |
withDimensions(java.lang.String dimensions)
Sets global reporter-wide dimensions and returns itself.
|
CloudWatchReporter |
withReporterFilter(com.google.common.base.Predicate<com.amazonaws.services.cloudwatch.model.MetricDatum> reporterFilter)
This filter is applied right before submission to CloudWatch.
|
CloudWatchReporter |
withTimestampLocal(boolean timestampLocal) |
CloudWatchReporter |
withTypeDimName(java.lang.String typeDimName) |
CloudWatchReporter |
withTypeDimValCounterCount(java.lang.String typeDimValCounterCount) |
CloudWatchReporter |
withTypeDimValGauge(java.lang.String typeDimValGauge) |
CloudWatchReporter |
withTypeDimValHistoSamples(java.lang.String typeDimValHistoSamples) |
CloudWatchReporter |
withTypeDimValHistoStats(java.lang.String typeDimValHistoStats) |
CloudWatchReporter |
withTypeDimValMeterCount(java.lang.String typeDimValMeterCount) |
CloudWatchReporter |
withTypeDimValTimerSamples(java.lang.String typeDimValTimerSamples) |
CloudWatchReporter |
withTypeDimValTimerStats(java.lang.String typeDimValTimerStats) |
@Deprecated public static final java.lang.String NAME_TOKEN_DELIMITER_RGX
Constants.NAME_TOKEN_DELIMITER_RGX@Deprecated public static final java.lang.String NAME_TOKEN_DELIMITER
Constants.NAME_TOKEN_DELIMITER@Deprecated public static final java.lang.String NAME_DIMENSION_SEPARATOR
Constants.NAME_DIMENSION_SEPARATOR@Deprecated public static final java.lang.String NAME_PERMUTE_MARKER
Constants.NAME_PERMUTE_MARKER@Deprecated public static final java.lang.String VALID_NAME_TOKEN_RGX
Constants.VALID_NAME_TOKEN_RGX@Deprecated public static final java.lang.String VALID_DIMENSION_PART_RGX
Constants.VALID_DIMENSION_PART_RGX@Deprecated public static final java.lang.String METRIC_TYPE_DIMENSION
Constants.DEF_DIM_NAME_TYPE. The default value will change from
"type" to @Deprecated public static final java.lang.String DEF_DIM_VAL_COUNTER_COUNT
Constants.DEF_DIM_VAL_COUNTER_COUNT. The default value will change from
"counterSum" to @Deprecated public static final java.lang.String DEF_DIM_VAL_METER_COUNT
Constants.DEF_DIM_VAL_METER_COUNT. The default value will change from
"meterSum" to @Deprecated public static final java.lang.String DEF_DIM_VAL_HISTO_SAMPLES
Constants.DEF_DIM_VAL_HISTO_SAMPLES. The default value will change from
"histogramCount" to @Deprecated public static final java.lang.String DEF_DIM_VAL_HISTO_STATS
Constants.DEF_DIM_VAL_HISTO_STATS. The default value will change from
"histogramSet" to @Deprecated public static final java.lang.String DEF_DIM_VAL_TIMER_SAMPLES
Constants.DEF_DIM_VAL_TIMER_SAMPLES. The default value will change from
"timerCount" to @Deprecated public static final java.lang.String DEF_DIM_VAL_TIMER_STATS
Constants.DEF_DIM_VAL_TIMER_STATS. The default value will change from
"timerSet" to public CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
ScheduledReporter instance. The reporter does not report metrics until
ScheduledReporter.start(long, TimeUnit).registry - the MetricRegistry containing the metrics this reporter will reportcloudWatch - clientpublic CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
java.lang.String metricNamespace,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
ScheduledReporter instance. The reporter does not report metrics until
ScheduledReporter.start(long, TimeUnit).registry - the MetricRegistry containing the metrics this reporter will reportmetricNamespace - (optional) CloudWatch metric namespace that all metrics reported by this reporter will
fall undercloudWatch - clientpublic CloudWatchReporter(com.codahale.metrics.MetricRegistry registry,
java.lang.String metricNamespace,
com.codahale.metrics.MetricFilter metricFilter,
com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync cloudWatch)
ScheduledReporter instance. The reporter does not report metrics until
ScheduledReporter.start(long, TimeUnit).registry - the MetricRegistry containing the metrics this reporter will reportmetricNamespace - (optional) CloudWatch metric namespace that all metrics reported by this reporter will
fall undermetricFilter - (optional) see MetricFiltercloudWatch - clientpublic CloudWatchReporter withDimensions(java.lang.String dimensions)
dimensions - (optional) the string representing global dimensionspublic CloudWatchReporter withTimestampLocal(boolean timestampLocal)
timestampLocal - Whether or not to explicitly timestamp metric data to now (true), or leave it null so that
CloudWatch will timestamp it on receipt (false). Defaults to false.public CloudWatchReporter withTypeDimName(java.lang.String typeDimName)
typeDimName - name of the "metric type" dimension added to CloudWatch submissions.
Defaults to "type" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValGauge(java.lang.String typeDimValGauge)
typeDimValGauge - value of the "metric type" dimension added to CloudWatch submissions of Gauges.
Defaults to when using either
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValCounterCount(java.lang.String typeDimValCounterCount)
typeDimValCounterCount - value of the "metric type" dimension added to CloudWatch submissions of
Counter.getCount().
Defaults to "counterSum" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValMeterCount(java.lang.String typeDimValMeterCount)
typeDimValMeterCount - value of the "metric type" dimension added to CloudWatch submissions of
Meter.getCount().
Defaults to "meterSum" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValHistoSamples(java.lang.String typeDimValHistoSamples)
typeDimValHistoSamples - value of the "metric type" dimension added to CloudWatch submissions of
Histogram.getCount().
Defaults to "histogramCount" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValHistoStats(java.lang.String typeDimValHistoStats)
typeDimValHistoStats - value of the "metric type" dimension added to CloudWatch submissions of
Histogram.getSnapshot().
Defaults to "histogramSet" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValTimerSamples(java.lang.String typeDimValTimerSamples)
typeDimValTimerSamples - value of the "metric type" dimension added to CloudWatch submissions of
Timer.getCount().
Defaults to "timerCount" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withTypeDimValTimerStats(java.lang.String typeDimValTimerStats)
typeDimValTimerStats - value of the "metric type" dimension added to CloudWatch submissions of
Timer.getSnapshot().
Defaults to "timerSet" when using
CloudWatchReporter constructors directly (backwards-compatibility) or
when using the CloudWatchReporterBuilderpublic CloudWatchReporter withReporterFilter(com.google.common.base.Predicate<com.amazonaws.services.cloudwatch.model.MetricDatum> reporterFilter)
MetricDatum.getDimensions().
Different from MetricFilter in that
MetricFilter must operate on the encoded, single-string name (see MetricFilter.matches(String, Metric)),
and this filter is applied before report(SortedMap, SortedMap, SortedMap, SortedMap, SortedMap) so that
filtered metrics never reach that method in this reporter.
Defaults to Predicates.alwaysTrue() - i.e. do not remove any metrics from the submission due to this
particular filter.
reporterFilter - to replace 'alwaysTrue()'public void report(java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> gauges,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> counters,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> histograms,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> meters,
java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> timers)
report in class com.codahale.metrics.ScheduledReporter