-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the behavior and expectations of NamingConvention #3108
Comments
I think the naming convention only applies to dot notation separation, not hyphens You mention 'name and labels', I only see the label being mentioned. Did I overlook a name example? |
If I do this: PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
Counter.builder("test.counter")
.tag("test.tag", "0")
.register(registry)
.increment();
System.out.println(registry.scrape()); I get this:
You need to use the |
|
@jonatan-ivanov @checketts |
so if PrometheusMeterRegistry is an exporter from actuator then it should follow https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels |
I'm not sure I understand what you are trying to say. |
|
spring-boot-starter-parent:2.6.5 and micrometer-registry-prometheus:1.8.3 it works |
from spring-boot, they are saying the bug is in micrometer-registry-prometheus:1.8.4 |
it is very bad in production because not valid Prometheus label Prometheus scraper will not save any metric in DB |
Ok. So you are saying with 1.8.3 it was working for you and with 1.8.4 it is now writing out names with hyphens instead of snake case? |
exectly that |
not every metric name or label(tag), only main-application-class="si.app.myApplication" |
ok, when using |
ok, when using namingConvention and commonTags , then main-application-class appears @Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> registry.config()
.namingConvention(NamingConvention.snakeCase)
.commonTags("env", "DEVELOPMENT");
} |
@Bean
MeterRegistryCustomizer<PrometheusMeterRegistry> metricsCommonTags() {
return registry -> registry.config()
.namingConvention(NamingConvention.snakeCase);
}
|
|
Thanks for that demo. It is a bug in SpringBoot actuator: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/startup/StartupTimeMetricsListener.java#L126 I didn't debug into why adding the customizer breaks it for you though. That shouldn't break the Prometheus ingestion though (just any queries you were expecting it) |
FWIW, I tried to sample with both Micrometer 1.8.3 and 1.8.4 and I didn't see any change in behaviour. The sample produced
I don't believe it is. AIUI, it's the naming convention's job to make the tag keys compatible.
It replaces |
|
|
is there any way with application configuration to add a prefix to each metric? |
That's not the behaviour that I see with your sample with the following
Can you provide an updated sample that reproduces the behaviour you have described when using |
You've already asked this in Spring Boot's issue tracker. Please don't ask the same question in multiple places. It risks wasting the time of those trying to help you. |
@wilkinsona thx |
In general, Micrometer expects its canonical naming (dot case) to be used for
The problem here is that |
|
They're not internal code. They are appropriate to use with some other metrics backends that are not as restrictive on allowed characters as Prometheus. They also can serve as a building block for users to make their own custom naming conventions, which requires them to be public API.
What is "everything"? Maybe it seems obvious for your use case that it includes I've reopened the ticket to better document this so it is hopefully more clear going forward. |
I’ve opened spring-projects/spring-boot#30536 to review things on the Boot side. The recommendation for dot-separated names seems to be pretty close to a requirement. I wonder if Micrometer 2.0 could make it a requirement or at least make the current API require dot-separated names with another API that’s more relaxed? |
I agree with @wilkinsona that requiring dot-separated names seems reasonable for 2.0 since it will eliminate a lot of potential guesswork. It will probably require some transition/migration in 1.x. such as logging a warning when a name does not comply with the requirement. Since there's a lot of entry points to create meters the only consistent place to validate such a requirement seems to be the constructor of |
We're not planning to do Micrometer 2.0 release any time soon, so what would be the consensus here for the 1.x branch? |
Describe the bug
Prometheus label is not snake case
Environment
To Reproduce
Expected behavior
Prometheus parser fail for label(tag) main-application-class it should be main_application_class
Additional context
The text was updated successfully, but these errors were encountered: