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.

StepWhat does itHow fast
ShedEach API process answers 503 with Retry-After past a cap on requests in flightAt once
More podsAn autoscaler per part adds copies on CPU15 to 30 seconds
Room for themOptional placeholder pods hold spare room (capacityReserve)Seconds
More nodesGKE adds a node when a pod cannot be placed1 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.

PartFloorCeilingTarget CPU
API, searches2860%
API, everything else2460%
Web app2470%
Each worker type1Per type70%
Parser12060%

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.size and 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.

StoreBacked up byKept
Postgres (Cloud SQL)A backup every day at 09:00 UTC, and point-in-time recovery14 backups, 7 days of point-in-time
Captain Vector DBA nightly job at 03:00 UTC writes a snapshot of each collection, per replica, to the bucket14 days
The bucketObject versioning. A replaced or deleted object is kept 30 days30 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=0

Jobs 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/metrics

This 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
AlertFires whenSeverity
CaptainPodCrashLoopingA container restarted more than 3 times in 30 minutesPage
CaptainComponentDownA part has no copy running for 5 minutesPage
CaptainVectorDbReplicaDownA replica is not ready for 10 minutesPage
CaptainDiskAlmostFullA disk has less than 15 percent freePage
CaptainComponentDegradedA part runs fewer copies than it should for 15 minutesTicket
CaptainPodStuckPendingA pod has waited 15 minutes to be placedTicket
CaptainOutOfMemoryA container was stopped for using more memory than its limitTicket
CaptainSnapshotFailedNo successful snapshot for more than 26 hoursTicket
CaptainJobFailedAn install job or the snapshot job failedTicket
CaptainAutoscalerAtCeilingAn autoscaler has run at its largest size for 30 minutesTicket

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 check

Not 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.

WhatCommand
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.

WayHowWhat is contacted
DownloadAn Admin presses "Download health report" on the Monitoring page, or the operator runs ./install.sh health-reportNothing. Read the file, then send it to Captain support yourself
SendSent with the health telemetry, to the host named at installThat one host, from the API only

Sending needs both switches, and they are set by two different people:

  1. The installer names the address Captain support gives you, under healthReport.endpoint in values.customer.yaml, adds its address ranges to captain_service_cidrs in terraform.tfvars, and runs ./install.sh.
  2. 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:

  1. The output of ./install.sh check.
  2. A health report, after you have read it.
  3. The version of the release.

Send them to your Captain team, or to humans@captain.dev.

Was this page helpful?