Reputation: 866
I need to have a percentile histogram of my metrics (http.server.requests). I have checked the documentation but I cannot make it work.
I'm not using promotheus so the properties here (https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/reference/html/production-ready-metrics.html#_per_meter_properties) doesn't work in my case.
I've tried to define a bean with implementing a DistributionStatisticConfig.
@Bean
public TimedAspect timedAspect(MeterRegistry registry) {
registry.config().meterFilter(
new MeterFilter() {
@Override
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
if (id.getName().startsWith("http.server.requests")) {
return DistributionStatisticConfig.builder()
.percentiles(0.5, 0.75, 0.9, 0.95)
.build()
.merge(config);
}
return config;
}
});
return new TimedAspect(registry);
}
I have a new metric that has been created with a new tag with the value of the percentile.
Any clue ?
Upvotes: 1
Views: 1713
Reputation: 6931
I need to have a percentile histogram of my metrics
First, you need a metrics backend that supports histograms, then if you enable it in Boot, see the docs: https://docs.spring.io/spring-boot/appendix/application-properties/index.html#application-properties.actuator.management.metrics.distribution.percentiles-histogram
For example:
management.metrics.distribution.percentiles-histogram.http.server.requests=true
I'm not using promotheus so the properties here (https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/reference/html/production-ready-metrics.html#_per_meter_properties) doesn't work in my case.
What metrics backend do you use? The properties you linked has nothing to do with Prometheus, they work with other backends too. Also, the version you linked (2.0.5) is very old and not supported, you should upgrade.
I've tried to define a bean with implementing a DistributionStatisticConfig.
You don't need to, see the property above. Also, you are not enabling histograms but you are enabling client-side percentiles. If you do this and you don't have histograms, that's expected (to enable histograms: .publishPercentileHistogram()
).
I have a new metric that has been created with a new tag with the value of the percentile.
It seems Micrometer is doing what you asked for (client-side percentiles), you did not ask for histograms. Btw the actuator endpoint will not show histograms (that would be too much data), also, it is not meant for publishing metrics in production, it is just a troubleshooting endpoint for your metrics (to see what metrics you have with what tags and if their value is changing or not), please do not scrape it.
Upvotes: 2