palbaseDocs

Palbase Machines · API

GET/databases/{name}/metrics

Read a database's usage over time

A database's usage, bucket by bucket, oldest first — what Studio's charts draw — kept by the hour and summed into days. traffic_bytes and awake_seconds are counters: what of the month's disk traffic (its own, its archive's padding taken off, as the database's traffic_bytes is) and of its awake time the meter counted in the bucket. They are counted at each minute's turn, into the hour of the minute that ended (what the meter counted in a month's last minute is in no hour: the month's count begins again before it is counted); a bucket with no row counted none. size_bytes and connections_max are gauges, absent when nothing was measured in the bucket: what the database held as last measured in it — it is measured while it is awake, never while it sleeps — and the most of its clients' connections to Postgres seen, every 15 seconds while it is awake: of every role but the platform's own, directly or through its pools. limits is what its size holds at most (size_bytes: past it, it turns read-only) and the connections it takes (Postgres' max_connections). Its history begins at the first minute the module counted it. Kept 90 days; what is older is deleted, and a purged database's within the hour after it was purged. A deleted database is read until it is purged, as it is at GET /databases/{name}. Buckets are UTC: hour, day.

Called by your server, with the project's secret key.

Path

namestring · requiredThe database's name: lowercase letters, digits and dashes, starting with a letter and not ending with a dash, 32 at most.

Query

window_secondsinteger · optionalHow far back the answer reaches, in seconds: 1 to 7776000 (90 days); 86400 when left out. Every bucket the window touches is answered whole: the first is the one its start falls in.
bucket"hour" | "day" · optionalWhat a row covers. When left out: hour for a window of 7 days or less, day beyond.
curl
curl -X GET "https://<your-ref>.palbase.studio/databases/<name>/metrics" \
  -H "apikey: $PALBASE_SECRET_KEY"

Responses

200The database's usage, oldest first

400Validation failed or a required field is missing

401Missing or invalid API key

403Not the project's secret key

404The project has no database of this name

429Over the project's request limit, or its machine time for this period is used up

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation GetDatabaseMetrics of machines's contract.