postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

How to generate QPS/TPS metrics with postgres_exporter?

Open hunterhuang8810 opened this issue 3 years ago • 4 comments

Hi,

I'm using postgres_exporter in our production database, I prefer to know is there methd to generate QPS/TPS metrics for Postgres instance? or via extend.query-path how to achieve that? Thanks a lot

hunterhuang8810 avatar Aug 12 '21 12:08 hunterhuang8810

--extend.query-path=custom.queries.yaml

TPS - xact_commit in pg_stat_database QPS - calls in pg_stat_statements

uspen avatar Aug 24 '21 08:08 uspen

--extend.query-path=custom.queries.yaml

TPS - xact_commit in pg_stat_database QPS - calls in pg_stat_statements

for QPS, calculate the difference between 1 second? i.e. sleep 1s count(calls) minus count(calls), or other method?

hunterhuang8810 avatar Aug 24 '21 08:08 hunterhuang8810

QPS is COUNTER, so just irate

uspen avatar Aug 24 '21 08:08 uspen

with                                                 
a as (select sum(calls) s from pg_stat_statements),     
b as (select sum(calls) s from pg_stat_statements , pg_sleep(1))     
select     
b.s-a.s          -- QPS    
from a,b;   

cobolbaby avatar Oct 31 '21 08:10 cobolbaby