Operations
Once an install is running, your team operates it day to day, and Captain supports it. Captain prepares the patches and new versions, and once the health report is on it watches basic health telemetry from the install, so it can see when a part is unhealthy without seeing any of your data. This page explains what the install does without help (scaling and backups), what it gives your own monitoring to read, how to rotate keys, and how Captain supports an install.
Scaling
When load rises suddenly, the install responds in four stages. Each stage is quicker than the one after it, so the faster ones cover the time the slower ones need.
| Step | What does it | How fast |
|---|---|---|
| Shed | Each API process answers 503 with Retry-After past a cap on requests in flight | At once |
| More pods | An autoscaler per part adds copies on CPU | 15 to 30 seconds |
| Room for them | Optional placeholder pods hold spare room (capacityReserve) | Seconds |
| More nodes | GKE adds a node when a pod cannot be placed | 1 to 3 minutes |
Searches run in their own Deployment, separate from uploads and indexing calls. This means a burst of indexing can add API pods of its own and cannot take CPU away from searches.
Each part has an autoscaler with a floor and a ceiling. These are the defaults.
| Part | Floor | Ceiling | Target CPU |
|---|---|---|---|
| API, searches | 2 | 8 | 60% |
| API, everything else | 2 | 4 | 60% |
| Web app | 2 | 4 | 70% |
| Each worker type | 1 | Per type | 70% |
| Parser | 1 | 20 | 60% |
A few more details are useful when planning capacity:
- The autoscalers are plain Kubernetes HorizontalPodAutoscalers, so nothing cluster-wide is installed by default.
- The node pool for workers grows from zero, and it uses spot machines by default.
- Each part spreads its copies across zones and keeps a disruption budget.
- Captain Vector DB's disks can grow without a restart when you raise
captain-vector-db.disk.sizeand run./install.sh software, but a disk cannot be made smaller.
Workers can also scale by the amount of work waiting in their queue, using KEDA. This option is off unless you set workers.autoscaling.keda: true. It is off by default because KEDA is installed cluster-wide and its operator can read objects by name in Captain's namespace, including the secrets.
Backups and restore
An install keeps data in three stores, and each one is backed up in its own way.
| Store | Backed up by | Kept |
|---|---|---|
| Postgres (Cloud SQL) | A backup every day at 09:00 UTC, and point-in-time recovery | 14 backups, 7 days of point-in-time |
| Captain Vector DB | A nightly job at 03:00 UTC writes a snapshot of each collection, per replica, to the bucket | 14 days |
| The bucket | Object versioning. A replaced or deleted object is kept 30 days | 30 days |
If CMEK is on, the backups and snapshots are encrypted with your keys, like the stores themselves.
Before any restore
Before restoring anything, stop the parts of the install that write data, so that nothing changes while the restore runs:
kubectl -n captain scale deployment captain-api --replicas=0
kubectl -n captain get deployments -o name | grep captain-worker- | xargs -r kubectl -n captain scale --replicas=0Jobs that were running stop at this point. Captain workflows remember them, and they start again once the workers are back. When the restore is finished, run ./install.sh software, which returns every part to its configured size and runs the install check.
Postgres
There are two ways to restore Postgres, depending on what went wrong.
If data was changed or deleted by mistake, go back to a point in time. Clone the instance as it was at that time (gcloud sql instances clone ... --point-in-time), dump the product database from the clone, and restore the dump over the install's database with pg_restore --clean --if-exists --exit-on-error. Delete the clone when you are done.
If the instance itself is damaged, restore a whole backup with gcloud sql backups restore. This replaces everything on the instance, including the state of running jobs.
Captain Vector DB
Captain Vector DB's snapshots are in the bucket at captain-vector-db/snapshots/<UTC time>/<replica>/<collection>.snapshot, with one file for each replica. To restore a collection, fetch the file for one replica, forward that replica's port to your machine, and upload the snapshot to it using Captain Vector DB's key. Then do the same for the other replica with its own file.
Captain tests the two file-based restores on every build: a Postgres dump and a Captain Vector DB snapshot are each restored into an empty store, and the result is compared with what went in. That shows the method works, but it does not replace practice on your own install, so run a restore there before you need one.
A restore also brings back any document that was deleted after the backup was taken. Delete those documents again once the restore is done.
Monitoring
Captain does not include a monitoring system. Instead, the install publishes metrics and alert rules for the monitoring you already run, and it adds a Monitoring page in the app for a quick view.
Metrics for your own monitoring
One address inside the cluster serves the install's metrics in Prometheus format:
http://captain-monitor.captain.svc:9465/metricsThis address is not on the load balancer, so it cannot be reached from outside the cluster. Inside the cluster, network rules allow only the namespaces you name, which should be the ones where your collectors run:
monitoring:
scrape:
namespaces: [gmp-system]The metrics are named captain_install_*. Every label value is a word from a fixed list, so the metrics never contain a file name, a question or a person's name.
Alert rules
Every install also carries a set of alert rules in Prometheus's rule format. Export them with the command below and load them into your Prometheus, or into Google Cloud Managed Service for Prometheus.
kubectl -n captain get configmap captain-alerts -o jsonpath='{.data.alerts\.yaml}' > captain-alerts.yaml| Alert | Fires when | Severity |
|---|---|---|
CaptainPodCrashLooping | A container restarted more than 3 times in 30 minutes | Page |
CaptainComponentDown | A part has no copy running for 5 minutes | Page |
CaptainVectorDbReplicaDown | A replica is not ready for 10 minutes | Page |
CaptainDiskAlmostFull | A disk has less than 15 percent free | Page |
CaptainComponentDegraded | A part runs fewer copies than it should for 15 minutes | Ticket |
CaptainPodStuckPending | A pod has waited 15 minutes to be placed | Ticket |
CaptainOutOfMemory | A container was stopped for using more memory than its limit | Ticket |
CaptainSnapshotFailed | No successful snapshot for more than 26 hours | Ticket |
CaptainJobFailed | An install job or the snapshot job failed | Ticket |
CaptainAutoscalerAtCeiling | An autoscaler has run at its largest size for 30 minutes | Ticket |
Whichever alert fires, these three commands are a good first look. The install check in particular calls every part and every model, and tells you which one is failing.
kubectl -n captain get pods
kubectl -n captain get events --sort-by=.lastTimestamp | tail -30
./install.sh checkNot covered
The alert rules do not cover everything, and it is better to know the gaps than to assume cover that is not there:
- A growing queue in Captain workflows raises no alert yet, so indexing can fall behind without one.
- The database is not covered. Use Cloud SQL's own alerts for disk, connections and replication.
- No rule watches for certificates or keys that are about to expire. The install check reports the age of each key instead.
- Spend is not covered, so set a budget alert on the project.
The Monitoring page
An install Admin opens the Monitoring page from Settings. It shows model calls for each job and provider, including calls refused for rate limit, retries and fallbacks. It also shows indexing, sync, the health of each service, disk use, and five alerts whose thresholds an Admin picks from a list.
The page is most useful for rate limits. Because the models run on your own quotas, a rate limit is yours to watch, and the page shows refusals rising before people start to see errors.
An Admin sets the five alert thresholds in Settings, Installation, under "Alerts and health report". Each one is a whole number inside the range shown beside the field.
The page stores counts only, with no question, file name or person in them. To show readiness and restarts, it relies on one small read-only pod, captain-monitor, which reads them from Kubernetes. That pod can be switched off, and the page then leaves those figures out.
Logs
Logs from the pods, the nodes and the database go to a log bucket of their own in the install's region. They are kept for 30 days by default (log_retention_days) and are kept out of the project's _Default bucket. Captain's logs contain no document, query or chat text.
Every Captain service logs under the install's own names: each line carries the name of the service that wrote it, such as captain-api, never the name of the person who made the request. Lines are structured, and they carry the job id or request id they belong to, so your team and Captain's support team can follow one indexing job or one search from service to service when something goes wrong. Captain Vector DB's lines are named by their pod label, and the API logs each call to it with the request id. They never carry document, query or chat text.
Rotating keys
No pod in the install has the right to change a secret, which is deliberate: a compromised pod cannot replace a key. The consequence is that a rotation has to be started from outside the install, by a person or by your own scheduler, with one of these commands.
| What | Command |
|---|---|
| The sign-in signing key | ./install.sh rotate signing-key |
| The internal keys | ./install.sh rotate internal-keys |
| A model key you brought | ./install.sh rotate model-key <secret name> |
| Everything this version offers | ./install.sh rotate all |
The internal keys are the ones the parts of the install use to call each other. They rotate in three passes, so that at every moment the key a part sends is one that every other part already accepts, and nobody is signed out while it runs. The Security page lists what each rotation affects and which keys have no command yet.
To help you keep to a rotation policy, the install check reports the age of every key each time it runs, which is on every install, every upgrade and every ./install.sh check:
OK key age, sign-in signing key: 41 days old (the policy is 365)How Captain supports an install
Captain supports every install it ships. Support rests on two things: basic health telemetry, which your team switches on with the health report during the install and which tells Captain how the install is running without carrying any of your data, and patches and new versions, which Captain prepares and delivers to you. Every access Captain has to an install is granted by you, and you can withdraw it at any time.
Patches and new versions
Captain prepares each patch and each new version of the Helm chart and the container images, and delivers it in the same form as every release: the installer kit and an offline image bundle that you load into your own registry. A patch is applied with the installer, either by your team or by Captain's support team with access that you grant for that purpose. That access is limited to the install, and you can withdraw it at any time. Installation describes how an upgrade runs.
Health telemetry
Once the health report is on, the install sends Captain basic health telemetry, so that Captain support can see when a part of the install is unhealthy without seeing any of your data. The telemetry describes the install's health and nothing else: which pods are running, their readiness and restarts, their resource use, the versions and image builds installed, and counts of Captain workflows and their outcomes.
Telemetry never carries logs, file contents, file names, queries, chat, chunk text, metadata values, the names of people or keys. Nothing is sent until your team switches the health report on during the install, together with the Captain team. It then goes to one outbound host, whose name is set at install, and the network rules allow that host and no other Captain address. The installer names the host, and an Admin switches sending on and can switch it off again at any time.
The health report
A health report is a more detailed snapshot than the telemetry, in one file that describes the health of an install in counts, so that Captain support can see what is wrong without seeing any of your data. Sending is off when the install ships, and you turn it on with your Captain team during the install. There are two ways to share a report, and both let you read it first.
| Way | How | What is contacted |
|---|---|---|
| Download | An Admin presses "Download health report" on the Monitoring page, or the operator runs ./install.sh health-report | Nothing. Read the file, then send it to Captain support yourself |
| Send | Sent with the health telemetry, to the host named at install | That one host, from the API only |
Sending needs both switches, and they are set by two different people:
- The installer names the address Captain support gives you, under
healthReport.endpointinvalues.customer.yaml, adds its address ranges tocaptain_service_cidrsinterraform.tfvars, and runs./install.sh. - An Admin opens Monitoring, Health report, and sets "Send health reports to Captain" to once a day or once an hour. Setting it back to Off stops sending within a minute.
If no host is named, the Admin's setting cannot be switched on, and nothing is sent.
A report holds a random id for the install, the version and image build numbers, each service's readiness and restarts, pod and node counts and memory, worker pool sizes, counts and durations of Captain workflows by type and outcome, error counts by code, model call counts, refusals and times by job and provider, sync run counts, disk use, alert counts, and settings that are not secrets.
A report never holds a file name, a path, a collection or organization name, a person's name or email, a question, a chat, document text, a metadata value, an address of your sources, your project's name, a model's name, or a key.
This is enforced by how the report and the telemetry are built. The install copies only the fields on an allow-list, so a field that is not on the list cannot leave the install. Every download and every send is written to the settings history with the name of the person who did it, and each report is kept in full so that you can read exactly what was shared.
What to send with a support request
Include these three things with a support request, because together they usually show where the problem is:
- The output of
./install.sh check. - A health report, after you have read it.
- The version of the release.
Send them to your Captain team, or to humans@captain.dev.