public interface MeterFilter
MeterRegistry
to create new metrics, allow for filtering out
the metric altogether, transforming its ID (name or tags) in some way, and transforming its
configuration.
All new metrics should pass through each MeterFilter
in the order in which they were added.
Modifier and Type | Method and Description |
---|---|
static MeterFilter |
accept()
Include a meter in published metrics.
|
default MeterFilterReply |
accept(Meter.Id id) |
static MeterFilter |
accept(java.util.function.Predicate<Meter.Id> iff)
When the given predicate is
true , the meter should be present in published metrics. |
static MeterFilter |
commonTags(java.lang.Iterable<Tag> tags)
Add common tags that are applied to every meter created afterward.
|
default DistributionStatisticConfig |
configure(Meter.Id id,
DistributionStatisticConfig config)
This is only called when filtering new timers and distribution summaries (i.e.
|
static MeterFilter |
deny()
Reject a meter in published metrics.
|
static MeterFilter |
deny(java.util.function.Predicate<Meter.Id> iff)
When the given predicate is
true , the meter should NOT be present in published metrics. |
static MeterFilter |
denyNameStartsWith(java.lang.String prefix)
Meters that start with the provided name prefix should NOT be present in published metrics.
|
static MeterFilter |
denyUnless(java.util.function.Predicate<Meter.Id> iff)
Can be used to build a whitelist of metrics matching certain criteria.
|
static MeterFilter |
ignoreTags(java.lang.String... tagKeys)
Suppress tags with given tag keys.
|
default Meter.Id |
map(Meter.Id id) |
static MeterFilter |
maxExpected(java.lang.String prefix,
java.time.Duration max)
Set a maximum expected value on any
Timer whose name begins with the given prefix. |
static MeterFilter |
maxExpected(java.lang.String prefix,
long max)
Set a maximum expected value on any
DistributionSummary whose name begins with the given prefix. |
static MeterFilter |
maximumAllowableMetrics(int maximumTimeSeries)
Useful for cost-control in monitoring systems which charge directly or indirectly by the
total number of time series you generate.
|
static MeterFilter |
maximumAllowableTags(java.lang.String meterNamePrefix,
java.lang.String tagKey,
int maximumTagValues,
MeterFilter onMaxReached)
Places an upper bound on the number of tags produced by matching metrics.
|
static MeterFilter |
minExpected(java.lang.String prefix,
java.time.Duration min)
Set a minimum expected value on any
Timer whose name begins with the given prefix. |
static MeterFilter |
minExpected(java.lang.String prefix,
long min)
Set a minimum expected value on any
DistributionSummary whose name begins with the given prefix. |
static MeterFilter |
renameTag(java.lang.String meterNamePrefix,
java.lang.String fromTagKey,
java.lang.String toTagKey)
Rename a tag key for every metric beginning with a given prefix.
|
static MeterFilter |
replaceTagValues(java.lang.String tagKey,
java.util.function.Function<java.lang.String,java.lang.String> replacement,
java.lang.String... exceptions)
Replace tag values according to the provided mapping for all matching tag keys.
|
static MeterFilter commonTags(java.lang.Iterable<Tag> tags)
tags
- Common tags.static MeterFilter renameTag(java.lang.String meterNamePrefix, java.lang.String fromTagKey, java.lang.String toTagKey)
meterNamePrefix
- Apply filter to metrics that begin with this name.fromTagKey
- Rename tags matching this key.toTagKey
- Rename to this key.static MeterFilter ignoreTags(java.lang.String... tagKeys)
tagKeys
- Keys of tags that should be suppressed.static MeterFilter replaceTagValues(java.lang.String tagKey, java.util.function.Function<java.lang.String,java.lang.String> replacement, java.lang.String... exceptions)
tagKey
- The tag key for which replacements should be madereplacement
- The value to replace withexceptions
- All matching tags with this value to retain its original valuestatic MeterFilter denyUnless(java.util.function.Predicate<Meter.Id> iff)
deny(Predicate)
.iff
- When a meter id matches, allow its inclusion, otherwise deny.static MeterFilter accept(java.util.function.Predicate<Meter.Id> iff)
true
, the meter should be present in published metrics.iff
- When a meter id matches, guarantee its inclusion in published metrics.static MeterFilter deny(java.util.function.Predicate<Meter.Id> iff)
true
, the meter should NOT be present in published metrics.
Opposite of denyUnless(Predicate)
.iff
- When a meter id matches, guarantee its exclusion in published metrics.static MeterFilter accept()
maximumAllowableTags(java.lang.String, java.lang.String, int, io.micrometer.core.instrument.config.MeterFilter)
.static MeterFilter deny()
maximumAllowableTags(java.lang.String, java.lang.String, int, io.micrometer.core.instrument.config.MeterFilter)
.static MeterFilter maximumAllowableMetrics(int maximumTimeSeries)
While this filter doesn't discriminate between your most critical and less useful metrics in deciding what to drop (all the metrics you intend to use should fit below this threshold), it can effectively cap your risk of an accidentally high-cardinality metric costing too much.
maximumTimeSeries
- The total number of unique name/tag permutations allowed before filtering kicks in.static MeterFilter maximumAllowableTags(java.lang.String meterNamePrefix, java.lang.String tagKey, int maximumTagValues, MeterFilter onMaxReached)
meterNamePrefix
- Apply filter to metrics that begin with this name.tagKey
- The tag to place an upper bound on.maximumTagValues
- The total number of tag values that are allowable.onMaxReached
- After the maximum number of tag values have been seen, apply this filter.static MeterFilter denyNameStartsWith(java.lang.String prefix)
prefix
- When a meter name starts with the prefix, guarantee its exclusion in published metrics.static MeterFilter maxExpected(java.lang.String prefix, java.time.Duration max)
Timer
whose name begins with the given prefix.prefix
- Apply the maximum only to timers whose name begins with this prefix.max
- The maximum expected value of the timer.static MeterFilter maxExpected(java.lang.String prefix, long max)
DistributionSummary
whose name begins with the given prefix.prefix
- Apply the maximum only to distribution summaries whose name begins with this prefix.max
- The maximum expected value of the distribution summary.static MeterFilter minExpected(java.lang.String prefix, java.time.Duration min)
Timer
whose name begins with the given prefix.prefix
- Apply the minimum only to timers whose name begins with this prefix.min
- The minimum expected value of the timer.static MeterFilter minExpected(java.lang.String prefix, long min)
DistributionSummary
whose name begins with the given prefix.prefix
- Apply the minimum only to distribution summaries whose name begins with this prefix.min
- The minimum expected value of the distribution summary.default MeterFilterReply accept(Meter.Id id)
id
- Id with map(io.micrometer.core.instrument.Meter.Id)
transformations applied.default Meter.Id map(Meter.Id id)
id
- Id to transform.@Nullable default DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config)
DistributionStatisticConfig
).id
- Id with map(io.micrometer.core.instrument.Meter.Id)
transformations applied.config
- A histogram configuration guaranteed to be non-null.