The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
## Backport of ai_usage_log table from v61
databaseChangeLog:
- logicalFilePath: migrations/060_update_migrations.yaml
- changeSet:
id: v60.gresdvx
author: nvoxland
comment: Create the ai_usage_log
preConditions:
- onFail: MARK_RAN
- not:
changeSetExecuted:
id: v61.gresdvx
author: nvoxland
changeLogFile: migrations/061/20260330_ai_usage_log.yaml
changes:
- createTable:
tableName: ai_usage_log
remarks: Universal ledger for all LLM API call usage tracking
columns:
- column:
name: id
type: bigint
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: created_at
type: ${timestamp_type}
defaultValueComputed: current_timestamp
constraints:
nullable: false
remarks: 'When the LLM call was made'
- column:
name: source
type: varchar(100)
constraints:
nullable: false
remarks: 'Origin of the LLM call, e.g. agent, slackbot, document-gen, intent-classification, example-question-gen, oss-sql-gen, semantic-search-embedding'
- column:
name: model
type: varchar(255)
constraints:
nullable: false
remarks: 'Full model identifier, e.g. anthropic/claude-sonnet-4-20250514'
- column:
name: prompt_tokens
type: int
constraints:
nullable: false
remarks: 'Number of input/prompt tokens'
- column:
name: completion_tokens
type: int
constraints:
nullable: false
remarks: 'Number of output/completion tokens'
- column:
name: total_tokens
type: int
constraints:
nullable: false
remarks: 'Sum of prompt_tokens + completion_tokens'
- column:
name: user_id
type: int
remarks: 'Metabase user who triggered the call. NULL for system/background calls.'
- column:
name: tenant_id
type: int
remarks: 'Snapshot of user tenant at request time. NULL for non-tenant users.'
- column:
name: conversation_id
type: varchar(36)
remarks: 'Reference to metabot_conversation. NULL for non-conversational calls.'
- column:
name: profile_id
type: varchar(100)
remarks: 'AI profile used, e.g. nlq, sql, slackbot'
- column:
name: request_id
type: varchar(36)
remarks: 'UUID for correlating with Snowplow events'
- changeSet:
id: v60.8g8esw
author: nvoxland
comment: Index on ai_usage_log.user_id
preConditions:
- onFail: MARK_RAN
- not:
changeSetExecuted:
id: v61.8g8esw
author: nvoxland
changeLogFile: migrations/061/20260330_ai_usage_log.yaml
changes:
- createIndex:
indexName: idx_ai_usage_log_user_id
tableName: ai_usage_log
columns:
- column:
name: user_id