50.2 DataSource metrics
The following metrics are exposed for each supported DataSource
defined in your application:
- The number of active connections (
datasource.xxx.active
) - The current usage of the connection pool (
datasource.xxx.usage
).
All data source metrics share the datasource.
prefix. The prefix is further qualified for each data source:
- If the data source is the primary data source (that is either the only available data source or the one flagged
@Primary
amongst the existing ones), the prefix isdatasource.primary
. - If the data source bean name ends with
DataSource
, the prefix is the name of the bean withoutDataSource
(i.e.datasource.batch
forbatchDataSource
). - In all other cases, the name of the bean is used.
It is possible to override part or all of those defaults by registering a bean with a customized version of DataSourcePublicMetrics
. By default, Spring Boot provides metadata for all supported data sources; you can add additional DataSourcePoolMetadataProvider
beans if your favorite data source isn’t supported out of the box. See DataSourcePoolMetadataProvidersConfiguration
for examples.