Skip to content

Add db connection monitoring #110

@marcmengel

Description

@marcmengel

We could have the metacat daemon polling and logging information like database connections, and slow queries
with variations on queries to pg_stat_activity in Postgresql:
SELECT client_addr, client_start, query_start, query FROM pg_stat_activity WHERE datname = 'hypot_dm_dev' and state='active' ;
we could then report connection counts to Landscape and long-running queries.
Or perhaps
'select client_addr, count(*) from pg_stat_activity WHERE datname = 'hypot_dm_dev' group by client_addr;'

Sample of getting this from psql:

dune_metadata_prd=> select client_addr, count(*) from pg_stat_activity WHERE datname = 'dune_metadata_prd' group by client_addr;
   client_addr   | count 
-----------------+-------
 131.225.67.132  |     4
 131.225.67.133  |     4
 131.225.67.247  |     1
 131.225.108.42  |     1
 131.225.240.229 |     4
 131.225.240.230 |     4
dune_metadata_prd=> select client_addr, count(*) from pg_stat_activity WHERE datname = 'dune_metadata_prd' and state='active' group by client_addr;
  client_addr   | count 
----------------+-------
 131.225.67.247 |     1

Note that we always see ourselves in the results (dunegpvm02 = 131.225.67.247 in this example), and so we should
not count our connection in the results...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions