Thread: [GENERAL] How to get login user name and host name in pgaudit

[GENERAL] How to get login user name and host name in pgaudit

From
rakeshkumar464
Date:
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.



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

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

From
Arthur Zakirov
Date:
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


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general