In micrometer, we can create a new gauge doing something like
myMeterRegistry.gauge("my_metric", 69);
See the code here https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java#L468
Would be possible to include a "prefix" name by default for my myMeterRegistry
object?
Manually, it should like:
myeterRegistry.gauge("myprefix_my_metric", 69);
My goal is that every developer that creates a gauge metric in my application does not have to take care of adding the "myprefix_" at the beginning of the metric name
Micrometer is a simple application metrics facade for the JVM. It has become the defacto standard in the Java ecosystem and is integrated into SpringBoot. Read more on Micrometer at micrometer.io. Instana supports Micrometer without any additional configuration.
MeterRegistry In Micrometer, a MeterRegistry is the core component used for registering meters. We can iterate over the registry and further each meter's metrics to generate a time series in the backend with combinations of metrics and their dimension values. The simplest form of the registry is SimpleMeterRegistry.
What is it? Micrometer is a dimensional-first metrics collection facade whose aim is to allow you to time, count, and gauge your code with a vendor neutral API. Through classpath and configuration, you may select one or several monitoring systems to export your metrics data to. Think of it like SLF4J, but for metrics!
Spring Boot provides a metrics endpoint that can be used diagnostically to examine the metrics collected by an application. The endpoint is not available by default and must be exposed, see exposing endpoints for more details. Navigating to /actuator/metrics displays a list of available meter names.
A MeterFilter would let you do that (but don't!):
new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
return id.withName("myprefix." + id.getName());
}
}
However a common prefix is typically a smell of an incorrect dimensionality. Usually users try to add a region, host, or the application's name as a prefix. Those are better provided as tags since then you can aggregate across systems and use common dashboards.
The commonTags
approach is recommended:
registry.config().commonTags("team", "myteam", "region", "us-east-1");
For hierarchical meter registries, tags will be included in the name as a prefix.
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