553217-ai-usage-data-all-clickhouse-support
What does this MR do and why?
This change adds support for storing and retrieving AI usage analytics data in ClickHouse as an alternative to the existing PostgreSQL.
Reason we are adding Clickhouse support is that:
- Postgres data has 3 month retention period while Clickhouse data are stored indefinitely
- Better performance when retrieving the data
References
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
-
Run seeds to populate Ai Usage data:
PROJECT_ID=your-project-id FILTER=ai_usage_stats bundle exec rake db:seed_fu
-
Optional: Comment out
authorize :read_enterprise_ai_analytics
inAiUsageDataType
-
Run the following query (with different event & date filtering):
query GetCodeSuggestionEvents($groupFullPath: ID!, $startDate: Date, $endDate: Date) {
group(fullPath: $groupFullPath) {
aiUsageData {
all(startDate: $startDate, endDate: $endDate, events:[CODE_SUGGESTION_ACCEPTED_IN_IDE]){
nodes {
event
timestamp
user {
id
username
}
}
}
}
}
}
Variables:
{
"groupFullPath": "Flightjs",
"startDate": "2025-09-01",
"endDate": "2025-09-30"
}
Switch variables and events filtering for
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #553217 (closed)
Edited by Amr Taha