Search code examples
javaspring-bootinfluxdbhikaricpmicrometer

Error when running SpringBoot 2 application with Micrometer metrics


I have a SpringBoot 2 application using the Micrometer framework, a Postgresql database, HikariCP as connection pool and an Influxdb to store the metrics. The application has been configured to use the micrometer-registry-influx dependency.

After adding some metrics to the application and starting up, the following error can be seen in the logs for the HikariCP connection pool metrics that are proivded by SpringBoot automatically:

    2018-05-23 10:24:33.594 ERROR 23220 --- [pool-1-thread-1] i.micrometer.influx.InfluxMeterRegistry  : failed to send metrics:
 {"error":"partial write: unable to parse 'hikaricp_connections,pool=HikariPool-1,metric_type=gauge value=NaN 1527063873587': invalid number
    unable to parse 'hikaricp_connections_active,pool=HikariPool-1,metric_type=gauge value=NaN 1527063873587': invalid number
    nunable to parse 'hikaricp_connections_idle,pool=HikariPool-1,metric_type=gauge value=NaN 1527063873588': invalid number
    unable to parse 'hikaricp_connections_pending,pool=HikariPool-1,metric_type=gauge value=NaN 1527063873588': invalid number dropped=0"}

The values for the metrics are only logged as Nan


Solution

  • This error was fixed in this commit of HikariCPm, which was released as version 2.7.9 and bundled with SpringBoot 2.0.2

    https://github.com/brettwooldridge/HikariCP/issues/1033

    After upgrading my application to SpringBoot 2.0.2, the error no longer appears and the metrics look ok in InfluxDB as well.