DEV Community

Cover image for I built this postgres logger
Kaushik Varanasi
Kaushik Varanasi

Posted on

I built this postgres logger

Postgres Logger

I used pgAudit to setup logging on my AWS RDS Postgres instance.

Disclaimer

I built (Rocketgraph)(https://rocketgraph.io/) which provides a complete backend. That includes Authentication, Hasura console for GraphQL, Postgres DB and serverless functions. So it let's you build web applications in minutes rather than in weeks.

see it in action

Image description

Try it out

Rocketgraph hosted

You can signup on Rocketgraph and create a project. The first project is free for 7 days and doesn't require CC.

This spins up a Postgres DB on AWS RDS instance with pgAudit configured.

Then, follow these steps to enable pgAudit:

Login to your RDS Postgres using psql like so:

psql postgresql://postgres:password@project-name.xxxxxxx.us-east-2.rds.amazonaws.com:5432/postgres
Enter fullscreen mode Exit fullscreen mode

Provided in your Rocketgraph dashboard

Create a role:

CREATE ROLE rds_pgaudit; 
Enter fullscreen mode Exit fullscreen mode

Then set log level:

ALTER DATABASE postgres set pgaudit.log="ALL"; 
Enter fullscreen mode Exit fullscreen mode

And enable extension:

CREATE EXTENSION pgAudit;
Enter fullscreen mode Exit fullscreen mode

self-hosted

To use pgAudit on your own Postgres instance, I wrote a detailed article here to setup: https://blog.rocketgraph.io/posts/install-pgaudit

Rocketgraph is open-source. Don't forget to star us here: https://github.com/RocketsGraphQL/rgraph

Top comments (0)