Re: How to get login user name and host name in pgaudit

From: Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: rakeshkumar464 <rakeshkumar464(at)outlook(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get login user name and host name in pgaudit
Date: 2017-10-22 19:15:31
Message-ID: 20171022191530.GA2004@arthur.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Oct 22, 2017 at 05:32:56AM -0700, rakeshkumar464 wrote:
> I installed latest pgaudit (1.2) with pg10. I am testing it and I see that
> it does not log the login user name and host name.
>
> For example, if user mary is running select * from sensitive_table, I want
> Mary and the machine from where she ran in the log.
>
> It seems to log the ids which needs to be joined with pg_ views to convert
> it into login user name and host name.
>
> any pointers on how to get it done.
>
> thanks.
>

According to the README [1] you need to set the log_line_prefix GUC
variable [2]. It's default value is '%m [%p]'. For example:

=# alter system set log_line_prefix to '%m [%p] %u %h';
=# select pg_reload_conf();

This GUC variable will change all log lines of PostgreSQL, not only
pgaudit's.

1 - https://github.com/pgaudit/pgaudit#format
2 - https://www.postgresql.org/docs/10/static/runtime-config-logging.html#guc-log-line-prefix

--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Arthur Zakirov 2017-10-22 19:58:33 Re: tgrm index for word_similarity
Previous Message Tom Lane 2017-10-22 19:13:47 Re: parray_gin and \d errors in PG10