claircore icon indicating copy to clipboard operation
claircore copied to clipboard

poolstats: support pgxpool metrics from two pools

Open frostmar opened this issue 1 year ago • 2 comments

Fixes https://github.com/quay/claircore/issues/1326

Support publishing pxgpool stats from two different pools as Prometheus metrics with different application_name labels.

A clair running in combo mode after:

$ curl -s localhost:6061/metrics | grep pgxpool

# HELP pgxpool_acquire_count Cumulative count of successful acquires from the pool.
# TYPE pgxpool_acquire_count counter
pgxpool_acquire_count{application_name="libindex"} 22
pgxpool_acquire_count{application_name="libvuln"} 2
# HELP pgxpool_acquire_duration_seconds_total Total duration of all successful acquires from the pool in nanoseconds.
# TYPE pgxpool_acquire_duration_seconds_total counter
pgxpool_acquire_duration_seconds_total{application_name="libindex"} 0.044675038
pgxpool_acquire_duration_seconds_total{application_name="libvuln"} 0.0325225
# HELP pgxpool_acquired_conns Number of currently acquired connections in the pool.
# TYPE pgxpool_acquired_conns gauge
pgxpool_acquired_conns{application_name="libindex"} 1
pgxpool_acquired_conns{application_name="libvuln"} 1
# HELP pgxpool_canceled_acquire_count Cumulative count of acquires from the pool that were canceled by a context.
# TYPE pgxpool_canceled_acquire_count counter
pgxpool_canceled_acquire_count{application_name="libindex"} 0
pgxpool_canceled_acquire_count{application_name="libvuln"} 0
# HELP pgxpool_constructing_conns Number of conns with construction in progress in the pool.
# TYPE pgxpool_constructing_conns gauge
pgxpool_constructing_conns{application_name="libindex"} 0
pgxpool_constructing_conns{application_name="libvuln"} 0
# HELP pgxpool_empty_acquire Cumulative count of successful acquires from the pool that waited for a resource to be released or constructed because the pool was empty.
# TYPE pgxpool_empty_acquire counter
pgxpool_empty_acquire{application_name="libindex"} 2
pgxpool_empty_acquire{application_name="libvuln"} 1
# HELP pgxpool_idle_conns Number of currently idle conns in the pool.
# TYPE pgxpool_idle_conns gauge
pgxpool_idle_conns{application_name="libindex"} 1
pgxpool_idle_conns{application_name="libvuln"} 0
# HELP pgxpool_max_conns Maximum size of the pool.
# TYPE pgxpool_max_conns gauge
pgxpool_max_conns{application_name="libindex"} 10
pgxpool_max_conns{application_name="libvuln"} 10
# HELP pgxpool_total_conns Total number of resources currently in the pool. The value is the sum of ConstructingConns, AcquiredConns, and IdleConns.
# TYPE pgxpool_total_conns gauge
pgxpool_total_conns{application_name="libindex"} 2
pgxpool_total_conns{application_name="libvuln"} 1

frostmar avatar Apr 24 '24 17:04 frostmar

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 56.24%. Comparing base (473f247) to head (4c5aa9e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1328      +/-   ##
==========================================
- Coverage   56.29%   56.24%   -0.06%     
==========================================
  Files         266      266              
  Lines       16846    16838       -8     
==========================================
- Hits         9484     9471      -13     
- Misses       6398     6402       +4     
- Partials      964      965       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 24 '24 17:04 codecov[bot]

bump - any chance of this being mergeable?

frostmar avatar May 01 '24 09:05 frostmar

Good find, I guess combo mode is getting slightly neglected these days

crozzy avatar May 10 '24 20:05 crozzy

Curious, do you run Clair in combo mode in production @frostmar?

crozzy avatar May 13 '24 15:05 crozzy

/fast-forward

crozzy avatar May 13 '24 16:05 crozzy

Curious, do you run Clair in combo mode ...

No, but we have a liveness probe added for the Postgres DB, which was recently updated to use a separate connpool, and I found it wasn't possible to see stats from more than one connpool! The combo mode made a nice recreate without needing anything outside the clair codebase

frostmar avatar May 13 '24 16:05 frostmar