This blog post "Micrometer: Spring Boot 2's new application metrics collector", mentions "The importance of dimensionality".
However, it doesn't include a sufficient example of how the associated tags can be set within a Spring Boot application.
Right now, I'm using Spring Boot 2's Micrometer interface to provide Prometheus-ready output without having done any Java-based configuration. Does setting, for example, a "host" tag require me to write some code? What would that look like?
Here's my entire configuration:
management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include: info,health,metrics,prometheus
There is a relevant example at metricsCommonTags, adapted below:
@Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> {
String hostname = "unknown";
try { hostname = InetAddress.getLocalHost().getHostName(); }
catch (Exception e) {}
registry.config().commonTags("host", hostname);
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With