Skip to content
AsterDrive Developer DocsDeveloper

Health Checks

Health checks are mounted at the repository root, not under /api/v1.

Both primary and follower nodes register this group.

MethodPathDescription
GET / HEAD/healthLiveness check
GET / HEAD/health/readyReadiness check covering the database, setup state, and lightweight prerequisites for the active node mode
GET/health/memoryHeap statistics, registered only in debug_assertions + openapi builds
GET/health/metricsPrometheus metrics; requires the metrics feature and explicit [observability.prometheus].enabled = true

Typical response:

{
"code": "success",
"msg": "",
"data": {
"status": "ok",
"version": "0.0.0",
"build_time": "2026-03-22T00:00:00Z"
}
}

build_time comes from the compile-time ASTER_BUILD_TIME environment variable. When the variable is unset, the build script falls back to the current UTC time.

HEAD /health has the same semantics, but returns no body.

This endpoint does more than a database ping. It checks the database and the active cache backend for every deployment profile. The single profile remains ready when an unavailable configured remote cache falls back to a healthy memory cache, while diagnostics report that state as degraded. Shared-runtime profiles require both the configured and active backend to be Redis. It then continues according to node mode:

  • primary: validates dynamic cluster topology and the authoritative setup state. needs_admin and needs_storage return 200 immediately; only ready requires a default storage policy, a constructible driver, and that driver’s lightweight readiness check
  • follower: checks the follower’s active storage driver and the state required for binding

This endpoint is meant to stay cheap. It does not perform remote S3 or remote-storage read/write/delete probes. Use the admin policy “test connection” action when you need to verify object storage credentials or permissions.

Successful primary responses use one of three data.status values:

  • needs_admin: 200; base dependencies are healthy, but the first administrator does not exist
  • needs_storage: 200; an administrator exists, but the default storage policy group or administrator assignment is incomplete
  • ready: 200; product setup is complete and the default driver’s lightweight readiness check passed

Error responses:

  • database unavailable: 503 with Database unavailable
  • an unhealthy active cache: 503 with Cache unavailable; in cluster deployments, an active backend that differs from configuration also returns 503, and both the configured and active backend must be Redis
  • invalid cluster topology, missing default policy, driver-construction failure, or lightweight readiness failure: 503 with Storage unavailable

Recommended deployment usage:

  • /health for liveness / basic probing
  • /health/ready for Kubernetes readiness; final launch validation must also require data.status = "ready"

Only debug_assertions + openapi builds register this endpoint.

It reports current heap allocation and peak usage as MB strings.

Requires the metrics feature and explicit [observability.prometheus].enabled = true; disabled by default. Output is Prometheus text exposition.

If you need metrics, build with:

终端窗口
cargo build --release --features metrics

or:

终端窗口
cargo build --release --features full

Dedicated static Basic Auth lives under [observability.prometheus.basic_auth]; see Monitoring for configuration, verifier generation, environment overrides and scraping. Primary/follower apply the same authentication before export/503, use no-store, and leave health/readiness unaffected. Missing, malformed, duplicate and incorrect credentials receive a uniform 401 + Basic challenge. Builds without pull capability and OTLP-only deployments do not register this endpoint.

HTTP and database:

MetricLabelsNotes
http_requests_totalmethod, route, statusRequest count
http_request_duration_secondsmethod, route, statusRequest latency histogram
db_queries_totalbackend, kind, statusSeaORM query count
db_query_duration_secondsbackend, kind, statusSeaORM query latency histogram

Auth, upload, download, and tasks:

MetricLabelsNotes
auth_events_totalaction, status, reasonLogin and refresh-token events
file_uploads_totalmode, statusUpload outcomes across direct / chunked / presigned modes
file_downloads_totalsource, outcome, rangeDownload outcomes
upload_sessions_totalmodeCreated upload sessions
upload_session_events_totalmode, event, statusSession lifecycle events
background_tasks_totalkind, statusTask state transitions
background_task_retries_totalkindRetry count
background_tasks_pendingnoneCurrent Pending / Retry backlog

Storage drivers:

MetricLabelsNotes
storage_driver_operations_totaldriver, operation, status, kindDriver operations
storage_driver_operation_duration_secondsdriver, operation, status, kindDriver latency histogram

Process metrics:

MetricLabelsNotes
process_memory_rss_bytesnoneResident set size
process_cpu_milliseconds_totalnoneTotal CPU time in milliseconds
process_uptime_secondsnoneUptime since metrics initialization

process_cpu_milliseconds_total is already exposed in milliseconds. process_uptime_seconds is monotonic rather than epoch-based.

The current schema is defined once in crates/aster_drive_metrics/src/lib.rs. Its pre-instance compatibility fixture preserves all prior product names, types, HELP, labels and buckets. New metrics cover actual body bytes, stream EOF/error/drop duration and in-flight counts; upload phases and persisted session backlog; capacity/support snapshots and admission rejection reasons; stored-blob cleanup backlog and retired backing bytes; remote probe state, tunnel lanes/reconnects and wire requests.

source=remote is follower-observed data-plane I/O and must not be added to primary user boundaries. Presigned/redirect flows bypassing AD have no fabricated bytes; AD followers carrying remote-presigned traffic do count their own observed bytes. Transfer bytes exclude TLS/HTTP framing. Completed upload replays do not recount phases. Cleanup retirement bytes are acknowledged backing accounting after row removal, not physical disk blocks; the independent pending timestamp survives retries and clears on referencing. Existing pending timestamps are backfilled from updated_at at upgrade.

Primary aggregates run every 60 seconds with a five-second DB budget; follower does not query primary backlog. Scrape does no business I/O. Filter snapshots by observability_snapshot_valid and a last-success age below 180 seconds. Capacity values require storage_capacity_known == 1; unsupported/unknown is not zero. observed_target_minimum contains independent minima over recent existing probe-cache observations, not summed or comparable numerator/denominator values. Staging filesystem usage includes the entire volume, while upload_staging_bytes explicitly reports declared/staged reservations and safety floor.

See the Chinese metric contract for the full type/unit/label table and runnable PromQL for throughput, failures, phase p95, backlog age, capacity and tunnel errors. P1 workspace quota aggregates and dedicated protocol-operation metrics remain follow-up work; tracing/Tempo is outside this metrics batch.