Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: pgAudit compatible #705

Open
dbajuliano opened this issue Nov 22, 2021 · 5 comments
Open

Request: pgAudit compatible #705

dbajuliano opened this issue Nov 22, 2021 · 5 comments

Comments

@dbajuliano
Copy link

Hi Darold

Would be amazing if we can get a friendly report or a tab from pgAudit entries, what do you think?

All your tools are amazing, thank you so much for the good work 馃

@darold
Copy link
Owner

darold commented Nov 22, 2021

Can you post a log sample and you want to see in the report so that I can see how and what pgAudit is logging?

@dbajuliano
Copy link
Author

Sorry about the very long delay.

I was thinking of having a pgAudit tab on pgBadger similar to the Overview/General Activity.
Something displaying the WRITE Statements: INSERT, UPDATE, DELETE, TRUNCATE, and COPY operations grouped by user. Also, the ROLE Statements: related to roles and privileges: GRANT, REVOKE, CREATE/ALTER/DROP ROLE. You could include other pgAudit statements if you want, but they are not from my interest in auditing.

Or maybe something simple like displays pgAudit entries in the Events/most-frequent-errors-events similar to the replication logs.

Here is a sample from pgAudit documentation: https://github.com/pgaudit/pgaudit#example-1

@hedayat
Copy link

hedayat commented Apr 18, 2022

Unfortunately, pgAudit doesn't log the duration of a query. However, if you enable duration logging with log_duration = on; you'll get the duration in the following line as below:

2022-04-18 13:28:29.510 +0430 [80843] LOG:  AUDIT: SESSION,5,1,READ,SELECT,,,"select *
	    from account;",<not logged>
2022-04-18 13:28:29.510 +0430 [80843] LOG:  duration: 0.418 ms

It'd be nice if pgBadger can parse such statements combined together too.

@darold
Copy link
Owner

darold commented Apr 18, 2022

Hi, pgBager is already able to do that, this is just that the pg_audit format is not supported.

@hedayat
Copy link

hedayat commented Apr 18, 2022

Yeah thanks, I just discovered the --log-duration option. :">

And note that the whole query is enclosed in "s and if there are "s in the query, they are specified as below:

Original query: select '"hi"';

pgAudit log:

2022-04-18 15:38:50.110 +0430 [87456] LOG:  AUDIT: SESSION,3,1,READ,SELECT,,,"select '""hi""';",<not logged>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants