Re: postgresql log parsing to report on user/db access

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: postgresql log parsing to report on user/db access
Date: 2012-04-25 15:49:07
Message-ID: 4F981CF3.3060801@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/25/2012 06:36 AM, Larry J Prikockis wrote:
> Is anyone aware of a quick solution for producing user/db access reports
> from pgsql syslog format logs?
>
> in other words, I have a bunch of lines such as:
>
>> Apr 22 06:39:04 147283-db3 postgres[13252]: [1800-1] user=database1_remote,db=sqm_remote_database1 LOG: connection authorized: user=database1_remote database=sqm_remote_database1...
> and I'd like to be able to generate weekly reports that provide rolled
> up statistics on which user connected to which db, how many times, etc.
>
What is the etc? You should be able to parse it pretty quickly with awk
but if you want additional stats like length of time a user connected it
will involve additional work.

Have you considered logging to the csv format?
http://www.postgresql.org/docs/9.1/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG

This may be an easier approach as you can just pull the data into a
table and report from there. Of course you can pre-filter the CSV with
grep or similar to avoid importing uninteresting lines.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben Chobot 2012-04-25 17:13:59 Updates, ShareLocks, RowExclusiveLocks, and deadlocks
Previous Message Larry J Prikockis 2012-04-25 13:36:16 postgresql log parsing to report on user/db access