micrometer
micrometer copied to clipboard
JDBC Metrics
Having metrics about database is very important. JDBC level metrics would be very nice like:
The total number of database reads
The total number of database writes
Number of reads per second (per minute, 5 minutes & 15 minutes)
Number of writes per second (per minute, 5 minutes & 15 minutes)
Average/median/percentile query times for reads & for writes
Here is a sample project: https://github.com/soulgalore/jdbcmetrics
This one seems also very usabe
https://github.com/gquintana/metrics-sql
I like the layered approach of metrics-sql
(apply at either driver, connection, or datasource level).
... or https://github.com/ttddyy/datasource-proxy
@ohr this is fantastic. Thanks for sharing.
I have a demo that uses a forked version of the metrics-sql library mentioned above to get metrics in micrometer format. https://github.com/pjfanning/slick-micrometer
I haven't modified the metrics to use micrometer tags yet.
@cemo https://spring.io/blog/2018/03/16/micrometer-spring-boot-2-s-new-application-metrics-collector - hikaricp has support for gathering micrometer metrics
@pjfanning It is metrics for connection pool not JDBC.
@cemo if you want jdbc metrics, see my comment about slick-micrometer sample
Thanks I will take a look.
@pjfanning nice job.
Brave's py6spy adds some instrumentation to the DB in terms of tracing - https://github.com/openzipkin/brave/tree/master/instrumentation/p6spy
FlexyPool has flexy-micrometer-metrics module. https://github.com/vladmihalcea/flexy-pool
here is a metrics list. https://github.com/vladmihalcea/flexy-pool/wiki/User-Guide#metrics
Is it possible to get JDBC Metrics that show durations of each SQL query run with micrometer? Or is this something still in the making? Just came across this issue and see that it is still not resolved, so I assume this still has to be done?
There is for sure a plan to add such support out of the box in Spring JDBC.
I see that you've been working already been working on having this out of the box in Spring JDBC in previous milestones. Any thoughts on when this might be supported?
We're planning to add it to Spring Framework 6. We've added similar support in Spring Cloud Sleuth 3.1.x but it's more about tracing than metrics.
Does this feature already entered 6.0-Msomething code or at least is it still planned in 6.0-GA? If yes, what will be exactly available? (e.g. which metrics)
It will be a third party project with autoconfiguration support for Spring Boot, see here: https://github.com/jdbc-observations/datasource-micrometer (work in progress).
With the new Micrometer Observation API in micrometer 1.10.0
, JDBC observation is supported by the datasource-micrometer library.
I will make a datasource-micrometer GA release, once Spring Boot 3 goes GA.
For metrics, you can see the documentation for what metrics are available by default. However, it does not create query-type-based metrics (e.g. read/write described in this issue) because it requires query parsing. Though it is possible to customize such behavior, similar to this "How to Modify the Query in Span". Instead of modifying queries in the tag here, you can apply your query parser to detect query type, then create appropriate meters.
In light of the datasource-micrometer with Observation API, I am closing this issue.