Skip to content
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

Prometheus tags are not included in exported metrics #24101

Closed
sbouchex opened this issue Nov 5, 2023 · 6 comments · Fixed by #24137
Closed

Prometheus tags are not included in exported metrics #24101

sbouchex opened this issue Nov 5, 2023 · 6 comments · Fixed by #24137

Comments

@sbouchex
Copy link
Contributor

sbouchex commented Nov 5, 2023

Overview of the issue

I have generated a simple JWT + angular + JDK17 monolytic app and tried to pull the prometheus metrics

Output looks like:
[...]
jvm_threads_states_threads{state="runnable",} 23.0
jvm_threads_states_threads{state="blocked",} 0.0
[...]

Whereas, it should be:
[...]
jvm_threads_states_threads{state="runnable",},application=jh80prom 23.0
jvm_threads_states_threads{state="blocked",},application=jh80prom 0.0
[...]

According to the application.yml:
spring:
application:
name: jh80prom

management:
prometheus:
metrics:
export:
enabled: true
tags:
application: ${spring.application.name}

Motivation for or Use Case

tag must be included and it was included in the JH7 app

Reproduce the error

Generate the app, start it and curl

JHipster Version(s)

8.0 and yes, it's a regression

JHipster configuration

See attachment

@sbouchex
Copy link
Contributor Author

sbouchex commented Nov 5, 2023

.yo-rc.json

@atomfrede
Copy link
Member

atomfrede commented Nov 6, 2023

As a workaround, you may add common tag via MeterRegistryCustomizer

@Value("${spring.application.name}")
String applicationName;
@Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
	return registry -> registry.config().commonTags("application", applicationName);
}

EDIT: Does setting a static tag via application.properties works?

@sbouchex
Copy link
Contributor Author

sbouchex commented Nov 6, 2023

@atomfrede Editing application.yml does not change anything

@sbouchex
Copy link
Contributor Author

sbouchex commented Nov 7, 2023

@atomfrede the tag is exported if I add
[...]
management:
metrics:
tags:
application: ${spring.application.name}
[...]

Sounds like the default yaml is wrong...

@atomfrede
Copy link
Member

Thanks, I obviously misread your original snippet. Yes the generated one is wrong (see official documentation https://docs.spring.io/spring-boot/docs/3.1.5/reference/htmlsingle/#application-properties.actuator.management.metrics.tags)

@mshima
Copy link
Member

mshima commented Nov 7, 2023

@sbouchex can you contribute with a PR?

sbouchex added a commit to sbouchex/generator-jhipster that referenced this issue Nov 7, 2023
@deepu105 deepu105 added this to the 8.1.0 milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants