|
| 1 | +# Prometheus Metrics |
| 2 | + |
| 3 | +DBLab Engine exposes Prometheus metrics via the `/metrics` endpoint. These metrics can be used to monitor the health and performance of the DBLab instance. |
| 4 | + |
| 5 | +## Endpoint |
| 6 | + |
| 7 | +``` |
| 8 | +GET /metrics |
| 9 | +``` |
| 10 | + |
| 11 | +The endpoint is publicly accessible (no authentication required) and returns metrics in Prometheus text format. |
| 12 | + |
| 13 | +## Available Metrics |
| 14 | + |
| 15 | +### Instance Metrics |
| 16 | + |
| 17 | +| Metric Name | Type | Labels | Description | |
| 18 | +|-------------|------|--------|-------------| |
| 19 | +| `dblab_instance_info` | Gauge | `instance_id`, `version`, `edition` | Information about the DBLab instance (always 1) | |
| 20 | +| `dblab_instance_uptime_seconds` | Gauge | - | Time in seconds since the DBLab instance started | |
| 21 | +| `dblab_instance_status` | Gauge | `status_code` | Status of the DBLab instance (1=active for status) | |
| 22 | +| `dblab_retrieval_status` | Gauge | `mode`, `status` | Status of data retrieval (1=active for status) | |
| 23 | + |
| 24 | +### Disk/Pool Metrics |
| 25 | + |
| 26 | +| Metric Name | Type | Labels | Description | |
| 27 | +|-------------|------|--------|-------------| |
| 28 | +| `dblab_disk_total_bytes` | Gauge | `pool` | Total disk space in bytes | |
| 29 | +| `dblab_disk_free_bytes` | Gauge | `pool` | Free disk space in bytes | |
| 30 | +| `dblab_disk_used_bytes` | Gauge | `pool` | Used disk space in bytes | |
| 31 | +| `dblab_disk_used_by_snapshots_bytes` | Gauge | `pool` | Disk space used by snapshots in bytes | |
| 32 | +| `dblab_disk_used_by_clones_bytes` | Gauge | `pool` | Disk space used by clones in bytes | |
| 33 | +| `dblab_disk_data_size_bytes` | Gauge | `pool` | Size of the data directory in bytes | |
| 34 | +| `dblab_disk_compress_ratio` | Gauge | `pool` | Compression ratio of the filesystem (ZFS) | |
| 35 | +| `dblab_pool_status` | Gauge | `pool`, `mode`, `status` | Status of the pool (1=active for status) | |
| 36 | + |
| 37 | +### Clone Metrics |
| 38 | + |
| 39 | +| Metric Name | Type | Labels | Description | |
| 40 | +|-------------|------|--------|-------------| |
| 41 | +| `dblab_clones_total` | Gauge | - | Total number of clones | |
| 42 | +| `dblab_clone_info` | Gauge | `clone_id`, `branch`, `snapshot_id`, `pool`, `status`, `protected` | Information about a clone (always 1) | |
| 43 | +| `dblab_clone_age_seconds` | Gauge | `clone_id` | Age of the clone in seconds since creation | |
| 44 | +| `dblab_clone_max_age_seconds` | Gauge | - | Maximum age of any clone in seconds | |
| 45 | +| `dblab_clone_diff_size_bytes` | Gauge | `clone_id` | Extra disk space used by the clone (diff from snapshot) | |
| 46 | +| `dblab_clone_logical_size_bytes` | Gauge | `clone_id` | Logical size of the clone data | |
| 47 | +| `dblab_clone_cpu_usage_percent` | Gauge | `clone_id` | CPU usage percentage of the clone container | |
| 48 | +| `dblab_clone_memory_usage_bytes` | Gauge | `clone_id` | Memory usage in bytes of the clone container | |
| 49 | +| `dblab_clone_memory_limit_bytes` | Gauge | `clone_id` | Memory limit in bytes of the clone container | |
| 50 | + |
| 51 | +### Snapshot Metrics |
| 52 | + |
| 53 | +| Metric Name | Type | Labels | Description | |
| 54 | +|-------------|------|--------|-------------| |
| 55 | +| `dblab_snapshots_total` | Gauge | - | Total number of snapshots | |
| 56 | +| `dblab_snapshot_info` | Gauge | `snapshot_id`, `pool`, `branch` | Information about a snapshot (always 1) | |
| 57 | +| `dblab_snapshot_age_seconds` | Gauge | `snapshot_id` | Age of the snapshot in seconds since creation | |
| 58 | +| `dblab_snapshot_max_age_seconds` | Gauge | - | Maximum age of any snapshot in seconds | |
| 59 | +| `dblab_snapshot_physical_size_bytes` | Gauge | `snapshot_id` | Physical disk space used by the snapshot | |
| 60 | +| `dblab_snapshot_logical_size_bytes` | Gauge | `snapshot_id` | Logical size of the snapshot data | |
| 61 | +| `dblab_snapshot_data_lag_seconds` | Gauge | `snapshot_id` | Time difference between snapshot data state and now | |
| 62 | +| `dblab_snapshot_max_data_lag_seconds` | Gauge | - | Maximum data lag of any snapshot in seconds | |
| 63 | +| `dblab_snapshot_num_clones` | Gauge | `snapshot_id` | Number of clones using this snapshot | |
| 64 | + |
| 65 | +### Branch Metrics |
| 66 | + |
| 67 | +| Metric Name | Type | Labels | Description | |
| 68 | +|-------------|------|--------|-------------| |
| 69 | +| `dblab_branches_total` | Gauge | - | Total number of branches | |
| 70 | +| `dblab_branch_info` | Gauge | `branch_name`, `pool`, `snapshot_id` | Information about a branch (always 1) | |
| 71 | + |
| 72 | +### Dataset Metrics |
| 73 | + |
| 74 | +| Metric Name | Type | Labels | Description | |
| 75 | +|-------------|------|--------|-------------| |
| 76 | +| `dblab_datasets_total` | Gauge | `pool` | Total number of datasets (slots) in the pool | |
| 77 | +| `dblab_datasets_available` | Gauge | `pool` | Number of available (non-busy) dataset slots for reuse | |
| 78 | +| `dblab_dataset_info` | Gauge | `pool`, `dataset_name` | Information about a dataset (1=busy, 0=available) | |
| 79 | + |
| 80 | +## Prometheus Configuration |
| 81 | + |
| 82 | +Add the following to your `prometheus.yml`: |
| 83 | + |
| 84 | +```yaml |
| 85 | +scrape_configs: |
| 86 | + - job_name: 'dblab' |
| 87 | + static_configs: |
| 88 | + - targets: ['<dblab-host>:<dblab-port>'] |
| 89 | + metrics_path: /metrics |
| 90 | +``` |
| 91 | +
|
| 92 | +## Example Queries |
| 93 | +
|
| 94 | +### Free Disk Space Percentage |
| 95 | +
|
| 96 | +```promql |
| 97 | +100 * dblab_disk_free_bytes / dblab_disk_total_bytes |
| 98 | +``` |
| 99 | + |
| 100 | +### Number of Active Clones |
| 101 | + |
| 102 | +```promql |
| 103 | +dblab_clones_total |
| 104 | +``` |
| 105 | + |
| 106 | +### Maximum Clone Age in Hours |
| 107 | + |
| 108 | +```promql |
| 109 | +dblab_clone_max_age_seconds / 3600 |
| 110 | +``` |
| 111 | + |
| 112 | +### Data Freshness (lag from current time) |
| 113 | + |
| 114 | +```promql |
| 115 | +dblab_snapshot_max_data_lag_seconds / 60 |
| 116 | +``` |
| 117 | + |
| 118 | +### Memory Usage per Clone |
| 119 | + |
| 120 | +```promql |
| 121 | +dblab_clone_memory_usage_bytes{clone_id="my-clone"} |
| 122 | +``` |
| 123 | + |
| 124 | +### CPU Usage per Clone |
| 125 | + |
| 126 | +```promql |
| 127 | +dblab_clone_cpu_usage_percent{clone_id="my-clone"} |
| 128 | +``` |
| 129 | + |
| 130 | +## Alerting Examples |
| 131 | + |
| 132 | +### Low Disk Space Alert |
| 133 | + |
| 134 | +```yaml |
| 135 | +- alert: DBLabLowDiskSpace |
| 136 | + expr: (dblab_disk_free_bytes / dblab_disk_total_bytes) * 100 < 20 |
| 137 | + for: 5m |
| 138 | + labels: |
| 139 | + severity: warning |
| 140 | + annotations: |
| 141 | + summary: "DBLab low disk space" |
| 142 | + description: "DBLab pool {{ $labels.pool }} has less than 20% free disk space" |
| 143 | +``` |
| 144 | +
|
| 145 | +### Stale Snapshot Alert |
| 146 | +
|
| 147 | +```yaml |
| 148 | +- alert: DBLabStaleSnapshot |
| 149 | + expr: dblab_snapshot_max_data_lag_seconds > 86400 |
| 150 | + for: 10m |
| 151 | + labels: |
| 152 | + severity: warning |
| 153 | + annotations: |
| 154 | + summary: "DBLab snapshot data is stale" |
| 155 | + description: "DBLab snapshot data is more than 24 hours old" |
| 156 | +``` |
| 157 | +
|
| 158 | +### High Clone Count Alert |
| 159 | +
|
| 160 | +```yaml |
| 161 | +- alert: DBLabHighCloneCount |
| 162 | + expr: dblab_clones_total > 50 |
| 163 | + for: 5m |
| 164 | + labels: |
| 165 | + severity: warning |
| 166 | + annotations: |
| 167 | + summary: "DBLab has many clones" |
| 168 | + description: "DBLab has {{ $value }} clones running" |
| 169 | +``` |
0 commit comments