Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot micrometer: enable percentiles histogram

I am trying to monitor response times of my Springboot service using micrometer (and prometheus).

Does anyone have an example of an application.properties or application.yaml file which succeeds in enabling the percentiles histogram? I have tried for example the following yaml configuration

logging:
  level:
    root: DEBUG
management:
  tracing:
    enabled: false
  endpoint:
    prometheus:
      enabled: true
    health:
      enabled: true
  endpoints:
    web:
      exposure:
        include: health, prometheus
  metrics:
    distribution:
      percentiles-histogram: true

But the application fails to start, when I add that last "metrics" section

***************************
APPLICATION FAILED TO START
***************************
Description: Failed to bind properties under 'management.metrics.distribution.percentiles-histogram' to java.util.Map<java.lang.String, java.lang.Boolean>
Property: management.metrics.distribution.percentiles-histogram
Value: \"true\"
Origin: class path resource [config/application.yaml] - 18:30
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Boolean] to type [java.util.Map<java.lang.String, java.lang.Boolean>]
Action:  Update your application's configuration

According to this https://docs.spring.io/spring-boot/reference/actuator/metrics.html, the customization management.metrics.distribution.percentiles-histogram controls Whether to publish a histogram suitable for computing aggregable (across dimension) percentile approximations. There is no example there, so I thought simply setting this to true might work, but it doesn't.

like image 920
engineerX Avatar asked Sep 01 '25 20:09

engineerX


1 Answers

The percentilesHistogram property is a Map<String, Boolean>, and its javadoc says:

Whether meter IDs starting with the specified name should publish percentile histograms. For monitoring systems that support aggregable percentile calculation based on a histogram, this can be set to true. For other systems, this has no effect. The longest match wins, the key 'all' can also be used to configure all meters.

Have you tried setting:

management:
  metrics:
    distribution:
      percentiles-histogram:
        all: true

And then check to see if is necessary to make a more fine-grained configuration?

like image 117
Francesco Poli Avatar answered Sep 03 '25 10:09

Francesco Poli