I tried the following distribution configs in Spring Boot 1.5.x.
3.1.1. Adding percentiles, histograms, and SLA boundaries
But it seems not working properly.
Version:
Config:
management:
metrics:
distribution:
percentiles:
http:
server:
requests: 0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 1.0
Exported metrics:
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="root",} 2.0
http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="root",} 0.034334051
http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="root",} 0.032477774
*In Spring Boot 2.0.x, the same setting works properly.
However, using the following config works properly.
management:
metrics:
distribution:
percentiles:
all: 0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 1.0
Exported metrics:
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.5",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.75",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.95",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.98",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.99",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="0.999",} 0.033030143
http_server_requests_seconds{exception="None",method="GET",status="200",uri="root",quantile="1.0",} 0.033030143
http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="root",} 1.0
http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="root",} 0.032699531
http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="root",} 0.032699531
Additionally, using the following config an exception occurred when my app launch.
management:
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true
Stack trace:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-04-23 23:06:39.674 ERROR 18574 --- [ main] o.s.boot.SpringApplication : Application startup failed
(abbreviated)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [io/micrometer/spring/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'limitCardinalityOfUriTag' defined in class path resource [io/micrometer/spring/autoconfigure/web/client/RestTemplateMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'limitCardinalityOfUriTag' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'management.metrics-io.micrometer.spring.autoconfigure.MetricsProperties': Could not bind properties to MetricsProperties (prefix=management.metrics, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'distribution.percentilesHistogram[http]' of bean class [io.micrometer.spring.autoconfigure.MetricsProperties]: Could not instantiate property type [java.lang.Boolean] to auto-grow nested property path; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Boolean]: Is it an abstract class?; nested exception is java.lang.InstantiationException: java.lang.Boolean
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
... 61 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'limitCardinalityOfUriTag' defined in class path resource [io/micrometer/spring/autoconfigure/web/client/RestTemplateMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'limitCardinalityOfUriTag' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'management.metrics-io.micrometer.spring.autoconfigure.MetricsProperties': Could not bind properties to MetricsProperties (prefix=management.metrics, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'distribution.percentilesHistogram[http]' of bean class [io.micrometer.spring.autoconfigure.MetricsProperties]: Could not instantiate property type [java.lang.Boolean] to auto-grow nested property path; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Boolean]: Is it an abstract class?; nested exception is java.lang.InstantiationException: java.lang.Boolean
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:519) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1188) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at io.micrometer.spring.autoconfigure.MeterRegistryPostProcessor.beansOfType(MeterRegistryPostProcessor.java:65) ~[micrometer-spring-legacy-1.0.0.jar:1.0.0]
at io.micrometer.spring.autoconfigure.MeterRegistryPostProcessor.getConfigurer(MeterRegistryPostProcessor.java:57) ~[micrometer-spring-legacy-1.0.0.jar:1.0.0]
at io.micrometer.spring.autoconfigure.MeterRegistryPostProcessor.postProcessAfterInitialization(MeterRegistryPostProcessor.java:47) ~[micrometer-spring-legacy-1.0.0.jar:1.0.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
... 71 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'management.metrics-io.micrometer.spring.autoconfigure.MetricsProperties': Could not bind properties to MetricsProperties (prefix=management.metrics, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'distribution.percentilesHistogram[http]' of bean class [io.micrometer.spring.autoconfigure.MetricsProperties]: Could not instantiate property type [java.lang.Boolean] to auto-grow nested property path; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Boolean]: Is it an abstract class?; nested exception is java.lang.InstantiationException: java.lang.Boolean
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:335) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:292) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
... 89 common frames omitted
Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'distribution.percentilesHistogram[http]' of bean class [io.micrometer.spring.autoconfigure.MetricsProperties]: Could not instantiate property type [java.lang.Boolean] to auto-grow nested property path; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Boolean]: Is it an abstract class?; nested exception is java.lang.InstantiationException: java.lang.Boolean
at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:931) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.createDefaultPropertyValue(AbstractNestablePropertyAccessor.java:899) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.setDefaultValue(AbstractNestablePropertyAccessor.java:887) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.getNestedPropertyAccessor(AbstractNestablePropertyAccessor.java:851) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:825) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:826) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:268) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanWrapper.setPropertyValue(RelaxedDataBinder.java:699) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:859) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.validation.DataBinder.doBind(DataBinder.java:755) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.validation.DataBinder.bind(DataBinder.java:740) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:272) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:330) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
... 103 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Boolean]: Is it an abstract class?; nested exception is java.lang.InstantiationException: java.lang.Boolean
at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:80) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:926) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
... 118 common frames omitted
Caused by: java.lang.InstantiationException: java.lang.Boolean
at java.lang.Class.newInstance(Class.java:427) ~[na:1.8.0_151]
at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:77) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
... 119 common frames omitted
Caused by: java.lang.NoSuchMethodException: java.lang.Boolean.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[na:1.8.0_151]
at java.lang.Class.newInstance(Class.java:412) ~[na:1.8.0_151]
... 120 common frames omitted
From my understanding Spring-Boot 1.5 can't cope with this kind of notation. What about?
management:
metrics:
distribution:
percentiles:
"[http.server.requests]": 0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 1.0
Thank you for the info.
The the following config works properly.
management:
metrics:
distribution:
percentiles-histogram:
"[http.server.requests]": true
sla:
"[http.server.requests]": 10ms, 100ms
percentiles:
"[http.server.requests]": 0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 1.0
It seems better to clarify that in the document of micrometer's Spring Boot 1.5 section.
I will send PR later.
@matsumana I think we do have that covered in the 1.5 docs:

@jkschneider
I noticed it just now.
Thank you for the info.
Most helpful comment
Thank you for the info.
The the following config works properly.
It seems better to clarify that in the document of micrometer's Spring Boot 1.5 section.
I will send PR later.