How to Configure Goose ClickHouse Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a goose clickhouse audit log by pairing dedicated database users with query logging. This setup tracks every SQL statement that the AI agent runs against your tables. Engineering teams often connect Goose to ClickHouse using shared admin keys to move fast. Broad permissions let an automated agent read private columns or change production data by mistake. A clear audit trail and strict user roles reduce this risk during daily tasks. How to set up a goose clickhouse audit log ClickHo

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 goose clickhouse audit log by pairing dedicated database users with query logging. This setup tracks every SQL statement that the AI agent runs against your tables. Engineering teams often connect Goose to ClickHouse using shared admin keys to move fast. Broad permissions let an automated agent read private columns or change production data by mistake. A clear audit trail and strict user roles reduce this risk during daily tasks.

How to set up a goose clickhouse audit log

ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. To turn on SQL access control, you first set a storage directory on the server. You also need at least one user with access management rights turned on. A user can only grant the privileges that they hold themselves. Creating a new user for Goose requires the create user privilege.

When you create the Goose user, you set its login method and allowed client hosts. You also assign default roles and specific user settings for the agent. Instead of full table access, you can grant read rights on specific columns only. The agent can then run queries that ask for those exact columns. If the agent runs a wildcard query, ClickHouse refuses it and returns no data. The wildcard query works only if the table holds just the granted columns. You can also use a trailing asterisk to grant rights by table name prefix.

Once the dedicated Goose user exists, native system logs record its activity by user name. You can read those system tables to review every query the agent ran. This gives your team a basic record of agent behavior inside the database.

What native database roles solve and what keeps the session active

Native roles and column grants stop Goose from reading unauthorized tables or blocked columns. Setting up a dedicated database user also makes it easy to filter native logs. You can see when the agent logged in and which tables it touched.

Still, native access rules only decide who can log in and which objects are visible. They do not inspect what individual statements do in flight before execution. If an allowed column holds emails, phone numbers, card numbers, or national IDs, queries return them. Data masking is needed so the system rewrites matched fields in results before returning them.

Audit Log Integrity + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static database keys stored on a developer laptop also create a security risk. If a local script leaks that key, anyone from an allowed host can log in. Finally, native database logs only show the SQL text that reached the server. They do not link the database query back to the user identity who ran Goose. Teams need query-level controls and active masking to run AI agents safely against live data.

Best practices for auditing AI agent queries

Start by separating human database accounts from automated tool accounts in every database cluster. Give each developer or workflow a distinct identity so audit logs stay clear and accurate. Review your column grants often to make sure new tables do not expose sensitive data.

Check your query logs each week for failed queries or denied wildcard statements. Failed queries often show where an AI agent tried to reach outside its allowed scope. Combine strict column grants with field masking to protect emails and card numbers in results.

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 beside the server as a sidecar for your ClickHouse and parses every statement before execution.

First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.

Frequently asked questions

How does ClickHouse handle wildcard queries when column grants are active?

ClickHouse refuses a wildcard select statement if the user only has rights on specific columns. It returns no data at all unless the table contains only the granted columns.

What server settings are needed to manage ClickHouse users with SQL?

You must configure the access control storage path on the server first. You also need at least one initial user with access management rights enabled.

Why is a dedicated database user important for an AI agent like Goose?

A dedicated user isolates the agent to specific tables, columns, and allowed hosts. It also tags every automated query in the system logs for faster auditing.

The query runs. The emails stay hidden.