How to Configure Azure Postgres Audit Log
You set up an azure postgres audit log by turning on server log settings. Then you send those database logs to a central cloud storage workspace. Most teams start by logging all statements from shared admin accounts. When roles are too broad, logs fill up fast and hide who ran which query. How the azure postgres audit log works with roles Database logging tracks actions based on the database role that runs the query. When a team member logs in, the engine checks their assigned role permission
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up an azure postgres audit log by turning on server log settings. Then you send those database logs to a central cloud storage workspace. Most teams start by logging all statements from shared admin accounts. When roles are too broad, logs fill up fast and hide who ran which query.
How the azure postgres audit log works with roles
Database logging tracks actions based on the database role that runs the query. When a team member logs in, the engine checks their assigned role permissions. You can set up group roles to manage permissions when you have many users. Users then get membership in the group role to do their daily work. Every query they run shows up under their database user name in the log.
Good logs start with tight role permissions inside the database engine. The special role name PUBLIC gives rights to every role on the system. By default, PUBLIC gets rights to connect and make temp tables on databases. It also gets rights to run functions and procedures right out of the box. The object owner can take back these default rights to lock things down.
In PostgreSQL 15 and later, defaults block users from making objects in the public schema. In older versions, an admin must take back that right from the PUBLIC role. You can also grant read rights on specific columns of a table or view. When you pair tight roles with logging, your audit trail becomes much clearer. You see which role read a table and when the event took place.
What native audit logs solve and what they miss
Native server logs do a great job of recording past database events. They help security teams check who logged in and what queries ran yesterday. They also record schema changes and failed login attempts across your cloud servers. If an admin drops a table, the log shows when that action happened.
Still, native logging only records history after a query has already finished running. The setup decides who logs in, not what individual statements do in flight. If a user has read rights on a table, they can pull every row by default. Note that read rights also let a user copy table data out. The log will show the query, but the raw data has already left.
Audit Log Integrity + Azure RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Shared database roles make this problem even worse for growing engineering teams. Many apps and engineers log in using the exact same database role. When that happens, the audit log only shows the shared role name. You cannot tell which actual person on your team ran a risky query. Also, native logs cannot mask fields like emails, phone numbers, or card numbers in results.
Why teams pair audit logs with query controls
Relying only on post-event logs puts your team in a reactive spot. You find out about a bad delete statement after the data is gone. You find out about exposed national IDs after someone downloads the full table. Fixing permissions across dozens of databases takes a lot of manual work.
Teams need a way to tie every single query to a real person. They also need a way to stop bad queries before they hit the server. Rewriting matched fields like card numbers in query results keeps sensitive data safe. Combining clear user identity with live controls closes the gap that server logs leave behind.
Add query and result controls beside Postgres
Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.
When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.
Frequently asked questions
Does the azure postgres audit log show the real user behind a shared role?
No, native database logs only record the database role used for the session. If five engineers share one admin role, all their queries look identical in the log.
Can native database audit logs stop a risky query from running?
No, an audit log only writes down events as they happen on the server. It cannot block a drop table command or require approval before a query runs.
Do read permissions allow users to export data while logging is on?
Yes, standard read privileges also allow users to copy table data out. The audit log records the event, but it does not rewrite emails or phone numbers.
Related guides
In this post