Add ClickHouse write model for AI Audit Events
What does this MR do and why?
Introduces the AuditEvents::AiAuditEvent ClickHouse write model for Duo Workflow
audit events.
ClickHouse migration — ALTER TABLE ai_audit_events adds 6 columns: namespace_id, author_name, target_id, target_type, target_details, entity_path
Model — Adds corresponding ActiveModel attributes and includes them in to_clickhouse_csv_row. group_id and namespace_id are both populated from whichever is set (backward compat for existing group_id column).
The service layer (separate MR) will derive author_name, entity_path, target_id, target_type, target_details from the workflow and current user at ingestion time. Without these columns in CH, events written to ClickHouse would be missing fields that the PostgreSQL path stores — causing different data depending on which backend is active.
- Adds
ai_audit_eventsClickHouse DDL todb/click_house/main.sql - Runs ClickHouse migration to create the
ai_audit_eventstable - Registers
ai_audit_eventsinDumpAllWriteBuffersCronWorker
How to set up and validate locally
- Setup clickhouse in gdk
- Run the ClickHouse migration:
cd gitlab/ bin/rake gitlab:clickhouse:migrate - Verify the table exists:
bin/rails runner "puts ClickHouse::Client.select('SELECT count() FROM ai_audit_events', :main).inspect"
# => [{"count()"=>0}]