1

In a microservices environment using postgresql, what would be the best method of capturing audit logs for table changes?

Need to not impact too much of DB performance and also capture a reliable log of database table changes and/or DDLs and the time and person performing the change

Many thanks in advance!

Reivax
  • 33
  • 2
  • I think you need to provide some more details about your requirements. It's possible to write an app (or hijack some open-source app) that ingests the WAL stream as a Logical Replicaion/Logical Decoding subscriber, and translate the contents into SQL statements as your audit log, if that's what you're asking for – richyen Dec 13 '19 at 18:37
  • 1
    Thanks richyen. I’m not quite familiar with db administration and how write ahead logs work. My situation is this, for the purpose of audit, we need to ensure that database table changes are logged. Understand that there are 2 types of logs that are required. 1) the exact sql that ran and performed a CRUD operation 2) the records and fields that are changed through the CRUD operation. Understand from my tech team that using db trigger as logging method would cause performance issues so using WAL is preferred. But wondering if the WAL method have other downsides as well. – Reivax Dec 15 '19 at 12:58
  • Can think of any negative points for your specific situation, as it’s probably the only way I know how. You can also read https://www.enterprisedb.com/postgres-tutorials/how-use-event-triggers-postgresql – richyen Dec 15 '19 at 21:56
  • Thanks! Richyen. I’ll try to do some more research on this. Maybe a combination of pgaudit and WAL – Reivax Dec 17 '19 at 00:21

0 Answers0