Skip to content

docs(adr): logs reach VictoriaLogs through the control plane (ADR 0029) - #452

Merged
samuelmbabhazi merged 2 commits into
mainfrom
docs/232-log-shipping
Nov 24, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
docs/232-log-shipping

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Part of #232 (M6.1). This records the maintainer's decision of 2026-11-24: logs reach VictoriaLogs through a dedicated stream to the control plane. It answers the decision PLAN step 4 was waiting for.

What changed

  • New ADR 0029:
    • ShipLogs(stream ShipLogsRequest) returns (stream ShipLogsResponse), an RPC beside Connect and ExecStream, not an action, so the closed action list is unchanged;
    • batches of at most 256 entries and 60 KiB, acknowledged once VictoriaLogs accepted them, with at most four in flight;
    • a cursor per container in the agent's local state, so logs come back after an outage, within Docker's json-file rotation;
    • labels set by the control plane from placed allocations, and a rate of 512 KiB/s per node with bursts of 4 MiB, past which acknowledgements wait;
    • VictoriaLogs in the control plane's Compose project, on its internal network only;
    • search and live tail through the API with environment.read, with the user's text quoted in LogsQL;
    • the agent replaces the values of a container's secret environment variables (8 bytes or more) with [redacted] before shipping.
  • ADR 0011: marked as amended.
  • SPEC: 3.1 (the RPC), 12 (the logs bullets) and the Appendix A skeleton.
  • PLAN: step 4 no longer waits for anything, and M6.1 is reworded.
  • THREAT_MODEL I1: names the redaction.
  • ARCHITECTURE: the diagram no longer puts logs on WireGuard.

Why

  • Not a direct push. ADR 0024's reasons against it for metrics hold for logs: a published port, a credential per agent, and labels set by the agent. Without WireGuard, which is out of v0.1.0, that port would face the internet.
  • Not Connect. Log volume would delay heartbeats and action updates behind it.

Choices made here (the more secure option, open to review)

  • Redaction on the agent. On the control plane, the ingest path would hold every application's decrypted secrets. Secrets mounted as files are not redacted, and the ADR says so.
  • Delivery. At-least-once from the cursor: a line may arrive twice, and none is lost while Docker still holds it.

How it was tested

Documentation only: Prettier ran through the pre-commit hook. The implementation PRs follow: proto, agent reader and stream, gateway and VictoriaLogs writer, Compose service, API routes, web UI.

Security considerations

  • No new port and no new credential on the agent.
  • Tenant isolation rests on the gateway's identity check and the control plane's labels.
  • The redaction narrows secret exposure in logs, and its limits are documented.

#232)

The maintainer chose a dedicated ShipLogs stream, as for metrics (ADR 0024): no published port, agent credential or agent label to trust. Acknowledged batches and a cursor per container let logs survive a control plane outage within Docker's rotation; the agent redacts secret environment values first.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ac29b5f and c51c4fb.

Files selected for processing: 6

  • docs/ARCHITECTURE.md
  • docs/PLAN.md
  • docs/SPEC.md
  • docs/THREAT_MODEL.md
  • docs/adr/0011-observability-stack.md
  • docs/adr/0029-logs-through-the-control-plane.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@samuelmbabhazi
samuelmbabhazi merged commit 35d4a27 into main Nov 24, 2026
25 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the docs/232-log-shipping branch November 24, 2026 21:57
samuelmbabhazi added a commit that referenced this pull request Nov 24, 2026
Part of #232 (M6.1). This is the contract of ADR 0029, stacked on #452,
the ADR itself. The agent's reader and stream, and the gateway's writer
to VictoriaLogs, follow in their own PRs.

## What changed

- **`proto/shipkeep/agent/v1/logs.proto`.**
  - `ShipLogsRequest` is `LogsOpen{lease_epoch}`, then `LogBatch`es.
  - A `LogBatch` has a `seq` starting at 1 and its entries.
- A `LogEntry` has the container name, a `LogStream` (stdout or stderr),
Docker's timestamp, the line (at most 16 KiB, UTF-8, redacted) and
`truncated`.
  - `ShipLogsResponse` is `LogAck{seq}`.
- **`gateway.proto`.**
- `rpc ShipLogs(stream ShipLogsRequest) returns (stream
ShipLogsResponse)`.
- `Welcome.logs`: the control plane keeps logs, so the agent opens the
stream.
- `ConfigUpdate.logs_endpoint` is marked `deprecated`, since the direct
push is gone. It was never set.
- Generated Go and TypeScript code (`pnpm gen`), and the `proto-ts`
export.

## Why

ADR 0029: a dedicated stream beside `Connect`, not an action, so the
closed action list is unchanged. With acknowledged batches, the agent
can keep a cursor and resend after an outage.

## How it was tested

- `buf lint` passes.
- `buf breaking` against `main` passes: the change only adds an RPC,
messages and a field.
- `go build ./agent/... ./lib/... ./cli/...` and the API typecheck pass.
- Nothing uses the new messages yet. Without a handler, the API's
gateway answers `ShipLogs` with `Unimplemented`, and the agent opens it
only when `Welcome.logs` is true, which nothing sets yet.

## Security considerations

- The agent's container name is only a key: the control plane maps it to
an allocation and never writes it as a label (ADR 0029).
- The bounds are stated in the proto and enforced by the next PRs: 256
entries and 60 KiB per batch, and 16 KiB per line.

---------

Signed-off-by: samuel mbabhazi <[email protected]>
samuelmbabhazi added a commit that referenced this pull request Nov 25, 2026
…461)

Part of #232 (M6.1): the control plane's half of ADR 0029. It is stacked
on #458 (the `ShipLogs` contract), which sits on #452 (the ADR). The
agent's shipper is the other half, in its own PR. VictoriaLogs joins the
Compose project in #460.

## What changed

- **Gateway, `ShipLogs`** (`fleet/interface/log-stream.ts`). It runs
behind the shared mTLS and database identity guard.
  - **Refusals:**
    - with no log store configured: `FAILED_PRECONDITION`;
- when the first frame is not `LogsOpen` with the node's current lease
epoch, read through `AuthenticateNode`: `FAILED_PRECONDITION`;
    - when batches are not numbered 1, 2, 3, …: `INVALID_ARGUMENT`.
- **Acknowledgement.** Each batch gets its `LogAck` only once the store
has kept it. A failed write ends the stream with `UNAVAILABLE` and no
acknowledgement, so the agent sends again from its cursor.
- **`Welcome.logs`** is true only when a store is registered.
- **`fleet/application/log-batches.ts`** is the hook the observability
module registers on, as `MetricsReports` is for metrics.
- **`observability`:**
  - **Domain, `domain/logs.ts`, pure:**
- entries are bounded: at most 256 per batch, a container name in the
agent's grammar, a valid time, a line of at most 16 KiB;
- labels come from the node's placed allocations: org, project, env,
app, instance (the replica), node and stream. A line of any other
container is dropped, and no name the agent sent becomes a label;
- a time more than 5 minutes from the control plane's clock is replaced
by it;
    - a per-node byte bucket allows 512 KiB/s with bursts of 4 MiB.
- **`LogsIngest`:** it registers only with a store, drops malformed
entries with a warning, maps containers in the tenant transaction, and
waits for the node's rate before writing.
- **`VictoriaLogsStore`:** `POST /insert/jsonline` with
`_stream_fields=org,app,instance,stream`, `_time_field` and
`_msg_field`, and a 10-second timeout. A failure never carries the
store's text.
- **Config:** `VICTORIALOGS_URL` is optional, as `VICTORIAMETRICS_URL`
is. The Compose file (#460) and `.env.example` set it.
- **SPEC 12:** the refusals and what is dropped.

## How it was tested

- **Domain:**
  - bounds and malformed entries;
- labels from the allocation, with the agent's container name absent
from the records;
  - the skew rule;
  - the token bucket.
- **Stream:**
  - in-order acknowledgements after the store kept each batch;
- a missing open, a stale epoch, out-of-order numbers and a second open
are refused;
  - no acknowledgement when the store fails;
  - the stream is refused without a store.
- **Ingest:** registration only with a store, labels and drops, waiting
past the rate, a store failure.
- **Store**, against a local HTTP server: the query and the JSON lines,
quotes and newlines included. A 500 fails without the server's text, and
no records means no request.
- `node-stream.spec.ts` passes the new dependency.
- `vitest --project api`: 764 tests pass, and ESLint is clean.

## Security considerations

- Tenant isolation rests on the certificate identity and the control
plane's records. An agent can only write lines for containers placed on
its own node, and every label is set here.
- The batch, line and rate bounds protect the API and VictoriaLogs from
a flooding agent: past its rate, a node waits instead of being dropped.
- Logs change no state, so nothing is audited, as for metrics (ADR
0024).

---------

Signed-off-by: samuel mbabhazi <[email protected]>
samuelmbabhazi added a commit that referenced this pull request Nov 25, 2026
…rt of #232) (#460)

Part of #232 (M6.1). This adds VictoriaLogs to the control plane's
Compose project, as ADR 0029 (#452) describes. Nothing writes to it yet:
the API's `ShipLogs` handler comes in a later PR.

## What changed

- **`deploy/control-plane/compose.yml`:** a `victorialogs` service,
mirroring `victoriametrics`:
- `victoriametrics/victoria-logs:v1.54.0`, pinned by digest, the same
pin as `deploy/dev/compose.yml`;
- `-retentionPeriod=30d`, `-memory.allowedBytes=256MiB`, and its data in
a `victorialogs-data` volume;
- a disk cap, since the disk is shared with PostgreSQL:
`-retention.maxDiskUsagePercent=80` drops the oldest days once the
filesystem is 80 % full, and `-storage.minFreeDiskSpaceBytes=1GiB`
refuses new lines below 1 GiB free (agents send them again);
- bounded searches: `-search.maxConcurrentRequests=4`,
`-search.maxQueryDuration=10s`;
- no published port, and alone on an internal `logs` network that only
`net` (the control plane's namespace) joins: PostgreSQL, the backup
containers and the migrations cannot reach it.

The control plane gets `VICTORIALOGS_URL: http://victorialogs:9428`. The
config schema already had the variable.
- **`compose.single-machine.yml`:** in `shipkeep-controlplane.slice`
with `mem_limit: 320m`, like VictoriaMetrics. Losing logs costs history,
not state.
- **`security.yml`:** Trivy scans the pinned image on amd64 and arm64.
- **`docs/INSTALL.md`:** the upgrade section names the image, its volume
(not in a PostgreSQL backup) and its disk cap, and says to replace
`compose.single-machine.yml` too on a single machine, passing both
files.
- **`docs/THREAT_MODEL.md`:** logs can hold a secret an application
printed; VictoriaLogs has no authentication, hence its own network.
- **`docs/MAINTAINING.md`:** the `victorialogs` Trivy scans are
optional, like the other pinned images.

## How it was tested

- `docker compose -f compose.yml -f compose.single-machine.yml config`
renders the service with its slice, memory limit and volume.
- In the lab (control plane installed from a bundle, separate form), the
new `compose.yml` replaced the old one and `docker compose up -d`
recreated the services. VictoriaLogs 1.54.0 runs with every flag above;
it is on `shipkeep_logs` only and `net` on both networks. PostgreSQL
neither resolves nor reaches it (`/dev/tcp` to its address fails), while
the control plane's namespace does. Lines an nginx replica printed
afterwards were shipped by the agent and found by the API's text and
stream search.
- CI runs the installer and bundle checks.

## Security considerations

- No new published port.
- Only the API reaches VictoriaLogs. Tenant labels are set by the API,
never by the agent (ADR 0029).
- The image is pinned by digest and scanned.

---------

Signed-off-by: samuel mbabhazi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant