Re: To monitor the number of PostgreSQL database connections?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: To monitor the number of PostgreSQL database connections?
Date: 2014-03-27 16:50:05
Message-ID: CAHyXU0zLWKN-6f4bwCv3SikNnWE=phOrQjRLKZ8x4kodvN0T0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 26, 2014 at 7:02 PM, David Johnston <polobo(at)yahoo(dot)com> wrote:
> Nithya Soman wrote
>> Hi
>>
>> Could you please provide any method (query or any logfile) to check
>> max connections happened during a time interval in psql DB ?
>
> Only if the time interval desired in basically zero-width (i.e.,
> instantaneous). The "pg_stat_activity" view is your friend in this.
>
> You have numerous options, including self-coding, for capturing and
> historically reviewing these snapshots and/or setting up monitoring on them.
>
> This presumes you are actually wondering "over any given time period how
> many open connections were there"? If your question is actually "In the
> given time period did any clients get rejected because {max connections}
> were already in use." you can check the PostgreSQL logs for the relevant
> error.

There's also some useful high level statistics (including connection
count) in pg_stat_database. For exact connection count over time
frame, I'd turn on log_connections in postgresql.conf and grep the
log.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dev Kumkar 2014-03-27 17:06:17 Re: Auditing Code - Fortify
Previous Message John R Pierce 2014-03-27 16:30:07 Re: Auditing Code - Fortify