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
Spring Boot 2 not collecting DataSource metrics #584
Comments
@AlexLardschneider Only datasources autoconfigured by Spring Boot are automatically instrumented. However, you can wire it manually: @Configuration
class DataSourceConfiguration {
@Bean
@Primary
fun dataSource(registry: MeterRegistry): DataSource {
val dataSource = org.apache.tomcat.jdbc.pool.DataSource()
...
DataSourcePoolMetrics(dataSource, listOf({ ds -> TomcatDataSourcePoolMetadata(ds) }), "tomcatDbPool").bindTo(registry)
return dataSource
}
} |
Thanks for getting back to me @jkschneider. Still having problems wiring it manually, are you sure the method parameters in your example are correct? IntelliJ is throwing errors (see screenshot). |
Sorry, I was writing code in the Github UI ;). Basically you just need to implement |
Thanks for the hints. For anyone else wondering about the solution: val provider = DataSourcePoolMetadataProvider { TomcatDataSourcePoolMetadata(dataSource) }
DataSourcePoolMetrics(dataSource as javax.sql.DataSource, provider, POSTGRES_DB_NAME, emptyList()).bindTo(registry) |
I am facing the same issue, Can you send me sample java code for the Same |
@prasan89 Based on the current Spring Boot reference documentation, instrumentation on
I confirmed it works automatically with a user-defined |
Hello,
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):
Is there anything else I need to configure for micrometer to start collecting datasource metrics?
The text was updated successfully, but these errors were encountered: