Class AggregateMetricReader
- java.lang.Object
- org.springframework.boot.actuate.metrics.aggregate.AggregateMetricReader
- All Implemented Interfaces:
MetricReader
public class AggregateMetricReader extends Object implements MetricReader
A metric reader that aggregates values from a source reader, normally one that has been collecting data from many sources in the same form (like a scaled-out application). The source has metrics with names in the form*.*.counter.**
and*.*.[anything].**
, and the result has metric names in the formaggregate.count.**
andaggregate.[anything].**
. Counters are summed and anything else (i.e. gauges) are aggregated by choosing the most recent value.- Since:
- 1.3.0
Constructor Summary
Constructors Constructor Description AggregateMetricReader(MetricReader source)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
The number of metrics known to this reader.Iterable<Metric<?>>
findAll()
Find all the metrics known to this reader.Metric<?>
findOne(String metricName)
Find an instance of the metric with the given name (usually the latest recorded value).void
setKeyPattern(String keyPattern)
Pattern that tells the aggregator what to do with the keys from the source repository.void
setPrefix(String prefix)
Prefix to apply to all output metrics.
Constructor Detail
AggregateMetricReader
public AggregateMetricReader(MetricReader source)
Method Detail
setKeyPattern
public void setKeyPattern(String keyPattern)
Pattern that tells the aggregator what to do with the keys from the source repository. The keys in the source repository are assumed to be period separated, and the pattern is in the same format, e.g. "d.d.k.d". The pattern segments are matched against the source keys and a rule is applied:- "d" means "discard" this key segment (useful for global prefixes like system identifiers, or aggregate keys a.k.a. physical identifiers)
- "k" means "keep" it with no change (useful for logical identifiers like app names)
- Parameters:
keyPattern
- the keyPattern to set
setPrefix
public void setPrefix(String prefix)
Prefix to apply to all output metrics. A period will be appended if not present in the provided value.- Parameters:
prefix
- the prefix to use (default "aggregator.")
findOne
public Metric<?> findOne(String metricName)
Description copied from interface:MetricReader
Find an instance of the metric with the given name (usually the latest recorded value).- Specified by:
findOne
in interfaceMetricReader
- Parameters:
metricName
- the name of the metric to find- Returns:
- a metric value or null if there are none with that name
findAll
public Iterable<Metric<?>> findAll()
Description copied from interface:MetricReader
Find all the metrics known to this reader.- Specified by:
findAll
in interfaceMetricReader
- Returns:
- all instances of metrics known to this reader
count
public long count()
Description copied from interface:MetricReader
The number of metrics known to this reader.- Specified by:
count
in interfaceMetricReader
- Returns:
- the number of metrics