Commit 737d527
Ship platform logs to Axiom via Vector (#240)
* ship platform logs to Axiom via Vector with cross-service request_id
Adds internal/obslog: JSON slog with a stable host envelope (service,
service_id, cell_id, region, hostname, host_ip, version) and per-request
fields (request_id, sandbox_id, worker_id) propagated via context. The
package installs itself as slog.Default AND redirects stdlib log.Printf
through slog so existing log call sites emit JSON automatically.
Wires obslog into both control plane (cmd/server, internal/controlplane,
internal/api/router) and worker (cmd/worker, internal/worker), replacing
echo's middleware.Logger with obslog.EchoMiddleware. internal/proxy
forwards X-Request-Id in the Director so worker log lines share the same
id as the control plane line for proxied requests.
internal/config adds OPENSANDBOX_CELL_ID and OPENSANDBOX_HOST_IP; CellID
defaults to "<region>-default" when unset.
deploy/vector/ ships Vector configs that read journald (worker, dev-host)
or docker_logs (control-plane), parse JSON, enrich non-JSON lines (kernel,
systemd) with the host envelope from env, and forward to a NEW Axiom
dataset oc-platform-logs — kept separate from the existing customer
oc-sandbox-logs dataset for cost / retention / blast-radius reasons.
install.sh accepts roles {worker, control-plane, dev-host}.
deploy/azure/deploy-azure-dev.sh: extend rsync excludes so local
dev-env-secrets-* and dev-vector-token-* files don't end up on the VM.
.gitignore: cover deploy/azure/.dev-vector-token-*.
Tests in internal/obslog cover the host envelope, context propagation,
the Echo middleware round-trip (including a forwarded X-Request-Id
appearing on both handler and access-log lines), and the link-local
filter in detectHostIP.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ship Vector via Packer + deploy-server: prod gets logs without a follow-up PR
Wires Vector install into both deploy paths so merging this PR doesn't
leave a "Vector still needs deploying" gap.
- deploy/vector/populate-vector-env.{sh,service}: systemd oneshot that
runs Before=vector.service. Reads SECRETS_VAULT_NAME from worker.env
(or server.env), fetches the platform-logs ingest token from Azure
Key Vault via the VM's managed identity (IMDS → AAD → KV REST), and
writes /etc/opensandbox/vector.env so Vector picks it up. Token never
appears in any image or workflow artifact. The script exits 0 on any
failure path (no IMDS, no vault, missing secret) so a logging
credential problem doesn't break the worker boot.
- deploy/vector/install.sh: installs Vector + drops the role config +
installs the populator unit + wires the systemd drop-in with the env
files (worker.env, server.env, vector.env). Idempotent. PACKER_BUILD=1
skips the systemctl start so the AMI capture doesn't trip over a
started service.
- deploy/vector/control-plane.yaml: rewrote from docker_logs to journald.
Current prod CP runs the server binary directly under systemd (per
deploy-server.yml), not in Docker.
- deploy/packer/worker-ami.pkr.hcl: new provisioner step that extracts
/tmp/packer-vector-ctx.tar.gz (created by CI in build-worker-ami.yml)
and runs install.sh worker with PACKER_BUILD=1. New worker AMIs come
out with Vector pre-installed and pre-configured; populator runs at
first boot to fetch the token.
- .github/workflows/build-worker-ami.yml: pre-tars deploy/vector/ to
/tmp/packer-vector-ctx.tar.gz before invoking Packer.
- .github/workflows/deploy-server.yml: bundles deploy/vector/ as
bin/vector-deploy.tar.gz, uploads to blob storage alongside the
server binary, and runs install.sh control-plane on each CP host via
az vm run-command (idempotent — refreshes the config on every deploy).
Operator prerequisite: create a `shared-axiom-platform-ingest-token`
secret in each prod KV. Documented in the PR description's env-vars
checklist.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* vector: rename CELL_ID/HOST_IP to OPENCOMPUTER_*; fetch dataset from KV too
Two reviewer-requested changes:
- Rename OPENSANDBOX_CELL_ID → OPENCOMPUTER_CELL_ID and
OPENSANDBOX_HOST_IP → OPENCOMPUTER_HOST_IP. New fields use the
product-named prefix; existing OPENSANDBOX_* fields untouched.
Touch: config.go (env var read), the three vector configs (VRL refs),
populate-vector-env.sh (env file write), install.sh (auto-detect),
vector.env.example.
- AXIOM_PLATFORM_DATASET is now also fetched from Key Vault as
`shared-axiom-platform-dataset` alongside the token. No default value
baked into the configs — a missing dataset secret fails Vector
healthcheck (loud) instead of silently shipping to a presumed default.
populate-vector-env.sh fetches both secrets in one pass with a shared
IMDS-acquired AAD token.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* keyvault: register shared-axiom-platform-{ingest-token,dataset}
Vector reads these from /etc/opensandbox/vector.env via the dedicated
populate-vector-env.service, but secretMapping is the documented source
of truth for "what shared-* secrets does this deployment need in KV".
Adding the entries so:
- operators have one place to audit required KV secrets
- the Go binary loads them into its own env at startup (side-effect),
so future admin endpoints / health views can surface platform-stream
config without a separate KV fetch
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent da5220c commit 737d527
24 files changed
Lines changed: 1192 additions & 9 deletions
File tree
- .github/workflows
- cmd
- server
- worker
- deploy
- azure
- packer
- vector
- internal
- api
- config
- controlplane
- obslog
- proxy
- worker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
97 | 105 | | |
98 | 106 | | |
99 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| |||
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
78 | 93 | | |
79 | 94 | | |
80 | 95 | | |
| |||
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
123 | 144 | | |
124 | 145 | | |
125 | 146 | | |
| |||
136 | 157 | | |
137 | 158 | | |
138 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
139 | 171 | | |
140 | 172 | | |
141 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
45 | 62 | | |
46 | 63 | | |
47 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
69 | 86 | | |
70 | 87 | | |
71 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
193 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
194 | 198 | | |
195 | 199 | | |
196 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
323 | 353 | | |
324 | 354 | | |
325 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
0 commit comments