Reputation: 101
I want to show some metrics using micrometer prometheus in combination with the spring-boot-actuator. My project is totally based on spring-boot and has the actuator feature enabled and mapped on the following url: http://localhost:9000/actuator Other endpoints are shown correctly but the http://localhost:9000/actuator/prometheus isn´t. Below you find a screenshot that I get when accessing this http-endpoint.
Can anybody help me? Why is this happening and how do i fix it? Cause normally prometheus is configured automatically for spring-boot-actuator when you provide the suitable dependency.
Upvotes: 6
Views: 25592
Reputation: 1
If someone still facing issue try adding this dependency : implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus-simpleclient', version: '1.13.5' it worked for me
Upvotes: 0
Reputation: 3234
I found that when I went to http://localhost:9999/actuator that I did not have prometheus showing up. I tried all the different configs, but my issue turned out to be a missing dependency
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
So I had the standard io:micrometer:micrometer-registry-prometheus, the applicaiton.property configs, and then this dependency.
Upvotes: 2
Reputation: 11
I had to enable the following property (Spring Boot 3.1.x) with everything else enabled.
management.prometheus.metrics.export.enabled=true
management.metrics.export.prometheus.enabled
is deprecated according to IntelliJ
Upvotes: 1
Reputation: 329
to me , this did the trick, with everything else enabled ( endpoints and metrics ) but without this, /actuactor/prometheus was not exposed
management:
metrics:
export:
prometheus:
enabled: true
Upvotes: 1
Reputation: 808
you need to check many things to be sure to enable Prometheus by Actuator
First thing you should put the following dependency on your pom.xml
to enable Prometheus on your project.
<!-- enable prometheus-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.10.2</version>
</dependency>
The second point you must check if the actuator exists on your project or not if doesn't exist, you need to add the following dependency.
<!--to enable actuator help to trace project-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
You need to add the following scripts to your application.yml to enable the actuator and Prometheus by actuator.
.
management:
security:
enabled: false
server:
port: 9000
endpoint:
metrics:
enabled: true
prometheus:
enabled: true
health:
show-details: always
show-components: always
probes:
enabled: true
shutdown:
enabled: true
info:
env:
enabled: true
enabled: true
endpoints:
web:
exposure:
include: prometheus, metrics, info, health, shutdown, beans
using the above script the actuator will run on port 9000 and you can send a request to the following URL to access the actuator.
http://localhost:9000/actuator/prometheus
and the following URL to access Prometheus
http://localhost:9000/actuator/prometheus
Note: you must check where you are writing your script because I was confused between endpoint and endpoints
Note: you can delete the port from application.yml
and the actuator will run by current application port
best luck
Upvotes: 5
Reputation: 77
In my case I was trying to set up prometheus on old project where was MetricsAutoConfiguration
excluded. So removing exclude solved the problem.
@EnableAutoConfiguration(exclude = { MetricsAutoConfiguration.class})
Upvotes: -1
Reputation: 101
ok i solved it with the solution:
i created a bean of type prometheusMeterRegistry manually and so spring boot didn't configure it automatically leading to no metrics provided at the prometheus endpoint see below code snippet for further details:
// @Bean
// public PrometheusMeterRegistry prometheusMeterRegistry() {
// return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
// }
Upvotes: -1
Reputation: 6903
This is auto-cofigured by default, here are some pointers for troubleshooting:
micrometer-registry-prometheus
(without defining the version, the version should come from the BOM)management.endpoints.web.exposure.include=*
/
, /actuator
, /actuator/prometheus
)curl localhost:9090/actuator/prometheus
Upvotes: 6