Analytics Quick Reference
Essential Query Patterns
Usage Analytics
Use for: High-level usage metrics and health monitoringUser Analytics
Use for: Understanding user behavior and identifying power usersAPI Analytics
Use for: Comparing API performance and usageBilling Queries
Use for: Usage-based billing and credit trackingTag-Based Filtering
Use for: Custom metadata filtering and endpoint analysisFilling Gaps in Time Series
Use for: Charts and visualizations that need consistent time intervalsTable Selection Guide
Choose the right table based on your time range:| Time Range | Recommended Table | When to Use |
|---|---|---|
| < 1 hour | key_verifications_v1 | Real-time analysis, detailed debugging |
| < 24 hours | key_verifications_per_minute_v1 | Hourly/daily trends, recent activity |
| < 30 days | key_verifications_per_hour_v1 | Daily/weekly analysis, user behavior |
| < 1 year | key_verifications_per_day_v1 | Monthly/quarterly reports, billing cycles |
| > 1 year | key_verifications_per_month_v1 | Annual trends, long-term analytics |
- Always filter by time first (uses indexes)
- Use
SUM(count)with aggregated tables, notCOUNT(*) - Add
LIMITclauses to prevent large result sets - Filter before grouping when possible
Common Filters
Automatic filtering: All queries are automatically filtered based on your root key permissions:
- Workspace: All queries are scoped to your workspace (no need to filter
workspace_id) - API: If your root key is scoped to a specific API (
api.<api_id>.read_analytics), queries are filtered to that API’skey_space_id. Withapi.*.read_analyticspermissions, filter bykey_space_idyourself.
Time Ranges
User & API Filters
Tag Filters
Outcome Filters
Need More Functions?
→ ClickHouse Function Reference→ ClickHouse SQL Documentation