Spring Boot 2 not collecting DataSource metrics
See original GitHub issueHello,
I recently upgraded my spring boot application to 2.0.1 to make use of the new micrometer Prometheus feature. According to the documentation, micrometer should automatically instrument all available DataSource objects and output the metrics as gauges.
However, it seems like that feature isn’t working in my case. Accessing /actuator/prometheus
I can see the various metrics micrometer collects, but no JDBC DataSource metrics.
My datasource is configured in its own spring configuration class (credentials omitted):
@Configuration
class DataSourceConfiguration {
@Bean
@Primary
fun dataSource(): DataSource {
val dataSource = org.apache.tomcat.jdbc.pool.DataSource()
dataSource.driverClassName = "org.postgresql.Driver"
dataSource.url = "jdbc:postgresql://$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB_NAME"
dataSource.username = POSTGRES_USER
dataSource.password = POSTGRES_PASSWORD
dataSource.initialSize = 2
dataSource.maxActive = 8
dataSource.maxIdle = 4
dataSource.minIdle = 1
dataSource.logValidationErrors = true
dataSource.timeBetweenEvictionRunsMillis = 34_000
dataSource.minEvictableIdleTimeMillis = 55_000
dataSource.maxWait = 10_000
dataSource.isRemoveAbandoned = true
dataSource.removeAbandonedTimeout = 60
return dataSource
}
}
Is there anything else I need to configure for micrometer to start collecting datasource metrics?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Spring boot 2 Prometheus not pulling db metrics
@Anoukh I have prometheus endpoint running but cannot find any datasource metrics.
Read more >57. Metrics - Spring
Spring Boot provides a metrics endpoint that can be used diagnostically to examine the metrics collected by an application. The endpoint is not...
Read more >49. Metrics - Spring
Spring Boot Actuator includes a metrics service with 'gauge' and 'counter' support. A 'gauge' records a single value; and a 'counter' records a...
Read more >Micrometer: Spring Boot 2's new application metrics collector
Micrometer is a dimensional-first metrics collection facade whose aim is to allow you to time, count, and gauge your code with a vendor ......
Read more >54. Metrics - Spring
54.1 Getting started. Spring Boot auto-configures a composite MeterRegistry and adds a registry to the composite for each of the supported implementations that ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the hints. For anyone else wondering about the solution:
@AlexLardschneider Only datasources autoconfigured by Spring Boot are automatically instrumented.
However, you can wire it manually: