Set DBWARDEN_METRICS=true and migrate and seed apply record counters, gauges, and histograms: migrations applied and migration errors as counters, migration duration as a histogram, and schema version, seed version, and pending migrations as gauges, all labeled by database. The metric types match what each question needs: a counter for how many times a migration ran, a gauge for the current schema version, a histogram for how long applies take.
The FastAPI plugin exposes them at /metrics via the MetricsRouter and MetricsMiddleware, so one scrape target covers both the application and the migration commands it runs. The dependency is optional: uv add "dbwarden[metrics]" installs prometheus-client, and without it every metric function is a safe no-op.
$ DBWARDEN_METRICS=true dbwarden migrateIs the metrics dependency optional?
Yes: uv add "dbwarden[metrics]" installs prometheus-client. When it is not installed or DBWARDEN_METRICS is unset, all metric functions are safe no-ops.
Which metrics does migrate record?
Counters for migrations applied and migration errors, a histogram for migration duration, and gauges for schema version, seed version, and pending migrations, all labeled by database.
Why does /metrics return 404?
The FastAPI endpoint is only active when prometheus-client is installed and DBWARDEN_METRICS=true is set. Disabled otherwise by design.