# SQLite backup metrics for Prometheus

A Litebackup server exports its throughput, requests, bucket backlog, disk, and host load at /metrics. Here is each metric and what it measures.

- [Monitoring guide](https://litebackup.com/sqlite-backup-monitoring)

## Useful queries

Counters end in _total, so take their rate.

```text
# Syncs per minute
sum(rate(litebackup_syncs_total[5m])) * 60

# Bytes received from machines and written to buckets, per minute
sum(rate(litebackup_upload_bytes_total[5m])) * 60
sum(rate(litebackup_archive_bytes_total[5m])) * 60

# 99th percentile request latency
histogram_quantile(0.99, sum by (le) (rate(litebackup_request_seconds_bucket[5m])))

# How long the oldest version has waited for a bucket
max(litebackup_archive_oldest_unarchived_seconds)
```

## Put SQLite in your cloud today

Run the server on a Linux machine, add a bucket you own, and back up a database with one command.

- [Install a server](https://litebackup.com/install)
- [Read the docs](https://litebackup.com/docs)

Counters end in `_total`, so chart their `rate()`. Gauges marked as measured once a minute change at most once a minute. The server answers `/metrics` on its health address, `127.0.0.1:8099` by default.

## Throughput

| Metric | Type | What it measures |
| --- | --- | --- |
| `litebackup_syncs_total` | counter | Versions committed by sync requests |
| `litebackup_upload_bytes_total` | counter | Bytes received by sync and stage requests |
| `litebackup_archive_bytes_total` | counter | Bytes of objects written to buckets |
| `litebackup_archive_objects_total{type}` | counter | Objects written to buckets, by type |
| `litebackup_archive_objects_deleted_total{reason}` | counter | Objects deleted from buckets by retention, garbage collection, or purge |

## Requests

| Metric | Type | What it measures |
| --- | --- | --- |
| `litebackup_requests_total{route,status}` | counter | API requests by route and status code |
| `litebackup_request_seconds{route}` | histogram | API request latency by route |
| `litebackup_rate_limited_requests_total{reason}` | counter | HTTP 429 responses with error code `rate_limited`, grouped by reason |
| `litebackup_pool_reserved_slots{pool}` | gauge | Slots reserved in each slot pool |
| `litebackup_pool_queued{pool}` | gauge | Requests queued for a slot in each pool |
| `litebackup_open_copies` | gauge | Database copies open on the server |

## Backups and buckets

| Metric | Type | What it measures |
| --- | --- | --- |
| `litebackup_databases` | gauge | Databases on the server |
| `litebackup_unarchived_versions` | gauge | Versions no bucket holds yet |
| `litebackup_unarchived_databases` | gauge | Databases with versions not yet in a bucket |
| `litebackup_archive_oldest_unarchived_seconds` | gauge | Age of the oldest version not yet in a bucket |
| `litebackup_late_archive_databases` | gauge | Databases past their archive delay |
| `litebackup_archive_integrity_errors_total` | counter | Restores from the bucket that found a missing or damaged object |
| `litebackup_bucket_check_age_seconds` | gauge | Seconds after the last bucket check that finished without failures |
| `litebackup_bucket_check_failures` | gauge | Bucket checks in a row that failed |
| `litebackup_retention_removal_backlog` | gauge | Objects retention gave up that are not deleted yet |
| `litebackup_replica_lag_seconds` | gauge | The longest lag of a replica that polled in the last 10 minutes |

## Disk and host

| Metric | Type | What it measures |
| --- | --- | --- |
| `litebackup_disk_free_bytes` | gauge | Free bytes on the data filesystem |
| `litebackup_disk_reserve_bytes` | gauge | Bytes the server holds in reserve before syncs pause |
| `litebackup_segment_fsync_seconds` | histogram | Time to fsync each synced record |
| `litebackup_cpu_usage_ratio` | gauge | Share of the CPU in use |
| `litebackup_memory_usage_ratio` | gauge | Share of the memory limit in use |
| `litebackup_pressure_some_ratio{resource}` | gauge | Share of the last minute some tasks stalled on CPU, memory, or IO |

## License

| Metric | Type | What it measures |
| --- | --- | --- |
| `litebackup_license_state` | gauge | 0 active, 1 ending, 2 in its grace period, 3 lapsed, -1 none |
| `litebackup_license_end_seconds` | gauge | The license's end date in Unix seconds |
