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_events ClickHouse DDL to db/click_house/main.sql
  • Runs ClickHouse migration to create the ai_audit_events table
  • Registers ai_audit_events in DumpAllWriteBuffersCronWorker

How to set up and validate locally

  1. Setup clickhouse in gdk
  2. Run the ClickHouse migration:
    cd gitlab/
    bin/rake gitlab:clickhouse:migrate
  3. Verify the table exists:
  bin/rails runner "puts ClickHouse::Client.select('SELECT count() FROM ai_audit_events', :main).inspect"
  # => [{"count()"=>0}]
Edited by Andrew Jung

Merge request reports

Loading