Skip to main content

Overview

PlanetScale serves a Prometheus-compatible metrics endpoint for each Neki branch. Prometheus finds these endpoints through HTTP service discovery. The same discovery list covers every active branch in your organization, including Neki branches. If you use Datadog, the Datadog agent can scrape the same Prometheus endpoint.

Connect Prometheus

You need Prometheus 3.x, or a Prometheus-compatible engine such as VictoriaMetrics, that supports HTTP SD.
  1. Create a service token in your organization settings. Save the token ID and the token.
  2. Grant the token the read_metrics_endpoints permission.
  3. Add a scrape configuration. Replace ${ORG}, ${TOKEN_ID}, and ${TOKEN} with your values:
Each discovered target carries a signature that expires after one day. Keep the refresh interval short so Prometheus always holds a valid signature. Each target returns the metrics of one branch. Prometheus attaches the planetscale_organization_name, planetscale_database_name, and planetscale_branch_name target labels, so you can tell branches apart. Every series also carries planetscale_database_branch_id. For managed Prometheus services that do not scrape, run Prometheus yourself and forward the metrics with remote_write.

Metrics

PlanetScale Neki emits the following metrics to be scraped. Every metric name starts with planetscale_. A histogram appears as three series with the suffixes _bucket, _sum, and _count. Counters and gauges appear under the name shown.

Router Metrics

Routers accept application connections, plan each statement, and send work to shards. These metrics describe the statements that routers handle.

Sidecar Pool Metrics

Each sidecar keeps a connection pool to its Postgres instance for each database. These metrics describe the pool. Use them to see when clients wait for a connection.

Postgres Metrics

These metrics come from the Postgres instances in each shard. Series from a primary carry planetscale_role="primary". Series from a replica carry planetscale_role="replica".

Backup Metrics

Infrastructure Metrics

These metrics describe the pods that run your branch. Router pods carry planetscale_router. Sidecar pods carry planetscale_shard and planetscale_role.

Example Queries

Replace your-branch-id with your branch ID.

Average router query latency

Sidecar pool utilization

The fraction of the pool that clients currently hold:

Average time a checkout waits for a pooled connection

Attributing Container Restarts

planetscale_pods_container_status_restarts_total counts every restart and carries no role or reason label. Join the metric that carries the one you want. To break restarts down by role, join planetscale_pods_status_phase:
To break restarts down by reason as well, filter against planetscale_pods_container_last_terminated_reason one minute at a time and join the role onto the result:
The gauge only reports a container’s latest termination reason, so the query attributes each minute’s restarts to the reason current in that minute, then sums over the hour. Change 1h to your own window and leave the 1m alone. A container that restarts twice inside one minute under two different reasons has both restarts attributed to the later one. Router pods carry no role, so their restarts appear in a series without a role label.

Tag Glossary

  • cluster: The PlanetScale cluster identifier
  • planetscale_cluster: The name of the Neki cluster that serves the branch
  • planetscale_database_branch_id: The unique identifier for the database branch
  • planetscale_pod: The Kubernetes pod name
  • planetscale_container: The container name (for example postgres, walg-daemon, router)
  • planetscale_component: The Neki component that owns the pod: nkrouter (router), nktablet (sidecar and Postgres), or nkadmin (admin)
  • planetscale_router: The router group name. Present on router pods
  • planetscale_shard: The shard identifier. Present on sidecar pods and Postgres metrics
  • planetscale_role: The role of the sidecar and its Postgres instance (for example primary or replica). Absent on router pods
  • planetscale_cell: The PlanetScale cell identifier
  • planetscale_phase: The pod’s status phase (Running, Pending, Failed, Succeeded, Unknown), or the phase of a backup restore
  • database: The database that a router session connected to, or the database that a sidecar pool serves
  • query_type: The type of SQL statement, such as SELECT or INSERT
  • error_class: The two-character class of the Postgres error code (SQLSTATE) of a failed query
  • le: The upper bound of a histogram bucket (less than or equal to)
  • planetscale_connection_state: The state of database connections
  • planetscale_lock_mode: The Postgres lock mode
  • planetscale_database_name: The Postgres database name
  • planetscale_restart_reason: Reason for a container’s most recent termination (OOMKilled, Error, Completed). Carried by planetscale_pods_container_last_terminated_reason
  • planetscale_waiting_reason: Reason a container is waiting (CrashLoopBackOff, ImagePullBackOff, and others). Carried by planetscale_pods_container_waiting_reason

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.