How to Configure Codex ClickHouse Audit Log
You set up a codex clickhouse audit log by creating a dedicated database user for the AI coding agent and recording its SQL queries in system log tables. This ties every query the agent runs to a separate database account. Many teams skip this step and let the agent share a personal login or a wide app role. When permissions are too broad, you cannot tell which queries came from a human and which came from the AI agent. A bad prompt or a loop can also read or change data across whole tables. H
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 a codex clickhouse audit log by creating a dedicated database user for the AI coding agent and recording its SQL queries in system log tables. This ties every query the agent runs to a separate database account. Many teams skip this step and let the agent share a personal login or a wide app role. When permissions are too broad, you cannot tell which queries came from a human and which came from the AI agent. A bad prompt or a loop can also read or change data across whole tables.
How to set up a codex clickhouse audit log
ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. To use SQL-driven access control, you first set a storage folder on the server and enable access management for an admin user. That admin user can only grant privileges that they hold themselves. With the right privilege, the admin creates a dedicated user account for the Codex agent.
During user setup, the admin defines how the agent logs in and which hosts it can connect from. You can also attach default roles and specific user settings to that account. When the AI agent connects with this account, the database tracks its activity under that specific user name. Admins can then query the system log tables to review the statements run by that account.
To limit what the agent can read, you can grant read access on specific columns rather than whole tables. If a user only has permission on two columns, queries asking for a third column will fail. A query that asks for all columns with a star also fails and returns no data, unless the table only has those granted columns. You can also grant read rights across tables that share a name prefix.
What native database logging solves and what it misses
Giving the AI agent its own user account and column grants solves basic tracking. Your team can check the database logs and see which SQL statements came from the agent account. Column grants also stop the agent from reading columns it was never granted.
Still, native database setup only decides who can log in and which objects they can touch. It does not inspect or filter what individual queries return in flight. If the agent needs to read a customer table, column grants are all or nothing. Native logs will record that a query ran, but raw emails, phone numbers, card numbers, or national IDs in the allowed columns still flow back to the agent context.
Audit Log Integrity + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static database accounts also require you to store database keys where the agent runs. Also, native logs only show the database account name. If ten developers run the same AI agent setup with one shared agent account, the database log cannot tell which developer triggered a specific query. It also cannot pause a risky query for human approval before it hits the database.
Why runtime query controls matter for AI agents
AI coding agents work fast and generate queries on their own. Relying on after-the-fact log reviews means you only find out about a bad query after the data has left the server. Teams need a way to link every agent query to the real human user who started the task.
They also need controls that act on the query and its results in real time. For example, data masking can rewrite matched fields like emails or card numbers in the query results before the agent processes them. That way, the agent can still test queries and fix code without pulling raw sensitive values into its prompt history.
Check ClickHouse queries and results before execution
Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits inline in the protocol beside the server as a sidecar for your ClickHouse. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations or hold them for review. Then hoop.dev data masking rewrites sensitive string columns in responses in memory and logs each decision per resource. Read the docs and source on GitHub.
Frequently asked questions
Why should an AI coding agent have its own ClickHouse user?
A separate user account lets you track the agent's queries in system logs and limit its host connections, roles, and column grants without changing human accounts.
What happens if Codex runs SELECT * with column-level grants?
ClickHouse refuses a star query and returns no data at all, unless the target table contains only the exact columns granted to that user.
Can native ClickHouse logs stop an agent from reading raw PII in allowed columns?
No, native logs only record the queries that ran, while data masking rewrites matched fields like emails, phone numbers, or card numbers in the results.
Related guides
In this post