Support property based MeterFilters
Add per-meter property support for `enabled`, `percentiles-histogram`, `percentiles` and `sla`. Fixes gh-11800
This commit is contained in:
@@ -1378,6 +1378,10 @@ content into your application. Rather, pick only the properties that you need.
|
||||
management.metrics.web.server.auto-time-requests=true # Whether requests handled by Spring MVC or WebFlux should be automatically timed.
|
||||
management.metrics.web.server.record-request-percentiles=false # Whether instrumented requests record percentiles histogram buckets by default.
|
||||
management.metrics.web.server.requests-metric-name=http.server.requests # Name of the metric for received requests.
|
||||
management.metrics.enabled.<name>= # Whether meter IDs starting-with the specified name should be enabled. The longest match wins, the key `all` can also be used to configure all meters.
|
||||
management.metrics.distribution.percentiles-histogram.<name>= # Whether meter IDs starting-with the specified name should be publish percentile histograms.
|
||||
management.metrics.distribution.percentiles.<name>= # Specific computed non-aggregable percentiles to ship to the backend for meter IDs starting-with the specified name.
|
||||
management.metrics.distribution.sla.<name>= Specific SLA boundaries for meter IDs starting-with the specified name. The longest match wins, the key `all` can also be used to configure all meters.
|
||||
|
||||
|
||||
# ----------------------------------------
|
||||
|
||||
@@ -65,6 +65,7 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
|
||||
:gradle-user-guide: https://docs.gradle.org/4.2.1/userguide
|
||||
:hibernate-documentation: https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html
|
||||
:jetty-documentation: https://www.eclipse.org/jetty/documentation/9.4.x
|
||||
:micrometer-concepts-documentation: https://micrometer.io/docs/concepts
|
||||
:tomcat-documentation: https://tomcat.apache.org/tomcat-8.5-doc
|
||||
// ======================================================================================
|
||||
|
||||
|
||||
@@ -1294,6 +1294,59 @@ Auto-configuration enables binding of a number of Spring Integration-related met
|
||||
|
||||
|
||||
|
||||
[[production-ready-metrics-per-meter-properties]]
|
||||
=== Customizing individual meters
|
||||
If you need to apply customizations to specific `Meter` instances you can use the
|
||||
`io.micrometer.core.instrument.config.MeterFilter` interface. By default, all
|
||||
`MeterFilter` beans will be automatically applied to the micrometer
|
||||
`MeterRegistry.Config`.
|
||||
|
||||
For example, if you want to rename the `mytag.region` tag to `mytag.area` for
|
||||
all meter IDs beginning with `com.example`, you can do the following:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{code-examples}/actuate/metrics/MetricsFilterBeanExample.java[tag=configuration]
|
||||
----
|
||||
|
||||
==== Per-meter properties
|
||||
In addition to `MeterFilter` beans, it's also possible to apply a limited set of
|
||||
customization on a per-meter basis using properties. Per-meter customizations apply to
|
||||
any all meter IDs that start with the given name. For example, the following will disable
|
||||
any meters that have an ID starting with `example.remote`
|
||||
|
||||
[source,properties,indent=0]
|
||||
----
|
||||
management.metrics.enable.example.remote=false
|
||||
----
|
||||
|
||||
The following properties allow per-meter customization:
|
||||
|
||||
.Per-meter customizations
|
||||
|===
|
||||
| Property | Description
|
||||
|
||||
| `management.metrics.enable`
|
||||
| Whether to deny meters from emitting any metrics.
|
||||
|
||||
| `management.metrics.distribution.percentiles-histogram`
|
||||
| Whether to publish a histogram suitable for computing aggregable (across dimension)
|
||||
percentile approximations.
|
||||
|
||||
| `management.metrics.distribution.percentiles`
|
||||
| Publish percentile values computed in your application
|
||||
|
||||
| `management.metrics.distribution.sla`
|
||||
| Publish a cumulative histogram with buckets defined by your SLAs.
|
||||
|
||||
|===
|
||||
|
||||
For more details on concepts behind `percentiles-histogram`, `percentiles` and `sla`
|
||||
refer to the {micrometer-concepts-documentation}#_histograms_and_percentiles["Histograms
|
||||
and percentiles" section] of the micrometer documentation.
|
||||
|
||||
|
||||
|
||||
[[production-ready-auditing]]
|
||||
== Auditing
|
||||
Once Spring Security is in play, Spring Boot Actuator has a flexible audit framework that
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License 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 org.springframework.boot.actuate.metrics;
|
||||
|
||||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Example to show a {@link MeterFilter}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class MetricsFilterBeanExample {
|
||||
|
||||
@Configuration
|
||||
static class MetricsFilterExampleConfiguration {
|
||||
|
||||
// tag::configuration[]
|
||||
@Bean
|
||||
public MeterFilter renameRegionTagMeterFilter() {
|
||||
return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area");
|
||||
}
|
||||
// end::configuration[]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user