-
Notifications
You must be signed in to change notification settings - Fork 2
Metrics Dashboard
The Metrics Dashboard provides comprehensive analytics for your D1 databases, powered by the Cloudflare GraphQL Analytics API.
The Metrics Dashboard features two tabs:
- π Query Volume - Total reads and writes across all databases
- β±οΈ Latency - Average P90 query latency
- π Rows Read - Total rows read (important for billing visibility)
- πΎ Storage - Total storage used across databases
- π Trend Charts - Query volume and rows read over time
- π Per-Database Breakdown - Detailed metrics for each database
- π Slow Query Analysis - Identify and optimize slow queries
- π Performance Summary - Critical, Moderate, and Fast query counts
- π Sortable Table - Sort by total time, avg time, count, or rows read
- π Query Details - View full SQL and detailed metrics
- Click the Metrics tab in the main navigation
- Select a time range (24h, 7d, or 30d)
- View summary cards and trend charts
Four cards at the top provide key metrics at a glance:
| Card | Description |
|---|---|
| Total Queries | Combined read and write queries |
| Rows Read | Total rows read across all databases |
| Avg P90 Latency | 90th percentile query latency |
| Total Storage | Combined storage for all databases |
Choose the time range for your metrics:
| Range | Description | Best For |
|---|---|---|
| Last 24 Hours | Hourly granularity | Recent activity monitoring |
| Last 7 Days | Daily granularity | Weekly trends |
| Last 30 Days | Daily granularity | Monthly planning |
An SVG-based line chart showing:
- Read Queries (blue line) - SELECT operations
- Write Queries (orange line) - INSERT/UPDATE/DELETE operations
Hover over data points to see exact values and timestamps.
A separate chart tracking rows read over time, useful for:
- Monitoring query efficiency
- Planning for billing (D1 charges based on rows read)
- Identifying usage spikes
Horizontal bar charts showing metrics for each database:
- Query count comparison
- Relative usage visualization
- Quick identification of high-traffic databases
A sortable table with columns for:
- Database name
- Read count
- Write count
- Rows read
- Storage size
- P90 latency
The Metrics Dashboard uses client-side caching for performance:
- Cache Duration: 2 minutes per time range
- Cache Key: Time range (24h, 7d, 30d)
- Refresh: Click the refresh button to bypass cache
The shorter TTL (2 minutes vs 5 minutes for other features) reflects the more dynamic nature of metrics data.
The Query Insights tab provides slow query analysis powered by Cloudflare's d1QueriesAdaptiveGroups GraphQL Analytics API.
Three summary cards show query distribution by performance:
| Card | Criteria | Description |
|---|---|---|
| Critical π΄ | >100ms avg | Queries needing immediate optimization |
| Moderate π‘ | 50-100ms avg | Queries that could benefit from optimization |
| Fast π’ | <50ms avg | Well-performing queries |
A sortable table lists your queries with these columns:
| Column | Description |
|---|---|
| Query | The SQL query string (truncated, expandable) |
| Total Time | Cumulative execution time |
| Avg Time | Average execution time per query |
| Count | Number of times the query was executed |
| Rows Read | Total rows read by the query |
Click any column header to sort. Click a row to expand and see:
- Full SQL query
- Rows written
- Detailed execution metrics
Queries are tagged with performance badges:
- π΄ CRITICAL - Average time >100ms
- π‘ WARNING - Average time 50-100ms
- π’ GOOD - Average time <50ms
For slow queries identified in Query Insights:
- Add Indexes: Use the Index-Analyzer to find missing indexes
- Limit Results: Add LIMIT clauses to paginated queries
- Filter Early: Add WHERE clauses to reduce rows scanned
- Avoid SELECT *: Only select columns you need
- Use Covering Indexes: Include all needed columns in the index
GET /api/metrics?range=24h|7d|30dQuery Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
range |
string | 24h |
Time range: 24h, 7d, or 30d
|
Response:
{
"success": true,
"result": {
"summary": {
"totalQueries": 125000,
"totalReads": 100000,
"totalWrites": 25000,
"totalRowsRead": 5000000,
"avgLatencyP90": 15.5,
"totalStorage": 52428800
},
"timeSeries": [
{
"timestamp": "2025-12-05T00:00:00Z",
"reads": 4500,
"writes": 1200,
"rowsRead": 225000
}
],
"databases": [
{
"databaseId": "uuid-...",
"databaseName": "my-database",
"reads": 50000,
"writes": 12500,
"rowsRead": 2500000,
"storage": 26214400,
"latencyP90": 12.3
}
]
}
}- Reads: SELECT queries that retrieve data
- Writes: INSERT, UPDATE, DELETE, and schema modification queries
- High read/write ratios are typical for most applications
- Sudden spikes may indicate issues or new features
D1 billing is based on rows read, so monitoring this metric helps:
- Predict monthly costs
- Identify inefficient queries
- Optimize database access patterns
Tips to reduce rows read:
- Use appropriate indexes
- Add WHERE clauses to limit results
- Use LIMIT for paginated queries
- Avoid SELECT * when possible
The P90 latency represents the 90th percentile query time:
- Values under 10ms are excellent
- 10-50ms is typical for D1
- Values over 100ms may indicate issues
High latency causes:
- Missing indexes
- Complex queries
- Large result sets
- Network issues
Storage includes:
- Table data
- Index data
- SQLite overhead
D1 storage is charged per GB, so monitor growth over time.
The Metrics Dashboard is designed with accessibility in mind:
- Screen Reader Support: ARIA labels on all interactive elements
- Keyboard Navigation: Full keyboard accessibility
- Color Contrast: WCAG-compliant colors for charts
- Text Alternatives: Data tables available alongside charts
- Check metrics daily for production databases
- Set up alerts for unusual activity (via webhooks)
- Review weekly trends for capacity planning
- Monitor rows read trends
- Optimize high-read queries with indexes
- Use caching where appropriate
- Consider read replicas for global distribution
- Watch for latency increases
- Use the Index Analyzer for recommendations
- Run ANALYZE (Optimize) after bulk operations
Causes:
- GraphQL API temporarily unavailable
- Invalid time range parameter
- Network connectivity issue
Solutions:
- Try refreshing the page
- Check Cloudflare status page
- Verify API credentials are correct
Causes:
- Data is cached (2 minute TTL)
- GraphQL API delay (up to 5 minutes)
Solutions:
- Click the refresh button
- Wait a few minutes for data propagation
Causes:
- Database was just created (metrics take time to appear)
- Database has no activity in selected time range
Solutions:
- Try a longer time range
- Run a query on the database to generate activity
- Database-Management - Managing your databases
- Index-Analyzer - Optimize query performance
- Database-Optimization - ANALYZE and performance tuning
- Webhooks - Set up alerts for metric thresholds
- API-Reference - Complete API documentation
Need Help? See Troubleshooting or open an issue.
- Database Management
- R2 Backup Restore
- Scheduled Backups
- Table Operations
- Query Console
- Schema Designer
- Column Management
- Bulk Operations
- Job History
- Time Travel
- Read Replication
- Undo Rollback
- Foreign Key Visualizer
- ER Diagram
- Foreign Key Dependencies
- Foreign Key Navigation
- Circular Dependency Detector
- Cascade Impact Simulator
- AI Search
- FTS5 Full Text Search
- Cross Database Search
- Index Analyzer
- Database Comparison
- Database Optimization