Skip to main content
The PlanetScale connection lists your databases and branches, pulls branch metrics every 5 minutes, and records deploy requests as deployments. Squasher uses a read-only organization service token. It does not change anything in PlanetScale.

Prerequisites

  • A PlanetScale organization, and permission to create service tokens and webhooks in it.
  • A Squasher API key with the project:write permission, if you connect with the CLI or the API. See API keys.

Create a service token

  1. In PlanetScale, open your organization settings and create a service token.
  2. Give the token these organization permissions. All of them are read-only.
  1. Copy the token ID and the token. PlanetScale shows the token one time.

Connect PlanetScale

  1. Open your project and select Settings in the sidebar, then the Integrations tab.
  2. On the PlanetScale card, select Connect.
  3. Enter the organization name, the token ID, and the token, then save.
Squasher checks the token before it saves the connection. The response gives the number of databases that the token can read and the webhook_url for the next step.

Send deploy events

Deploy requests and branch events come from a PlanetScale webhook. Squasher records each event as a deployment.
1

Add the webhook in PlanetScale

In the database settings in PlanetScale, add a webhook. Use the webhook URL that Squasher shows after you connect. Select the deploy_request.* events and branch.ready.
2

Save the signing secret in Squasher

PlanetScale shows a signing secret for the webhook. Squasher uses it to check each delivery. Paste it on the PlanetScale card, or pipe it to the CLI:
The API request is PUT /v1/projects/{project_id}/provider-connections/planetscale/webhook with {"secret": "..."}. The secret has at least 8 characters.
Squasher drops a delivery when its x-planetscale-signature does not match the saved secret.

What Squasher pulls

Every 5 minutes, Squasher reads the database and branch list and the Prometheus metrics endpoint of each branch. It stores the metrics as OpenTelemetry metrics, for example planetscale_vtgate_query_executions_total, planetscale_vtgate_errors_total, planetscale_vtgate_queries_duration, planetscale_mysql_replica_lag_seconds, and planetscale_pods_cpu_util_percentages. Squasher sends your service token only to https://api.planetscale.com. It does not read a metrics endpoint on any other host. Each branch metric has these resource attributes: Query the metrics in Metrics, or see the databases and branches with their key metrics under Infrastructure, on the Providers tab.

Check the connection

Each stream shows its freshness, the time of the last success, and the last error.

Troubleshooting

Next steps

Provider connections

Connect other providers and check their state.

Deployments API

Read the deployments that deploy requests create.