Skip to main content

NATS Subjects

Reference for the NATS subject hierarchy used by Proxima Console.

System Subjects

SubjectPatternDirectionDescription
Config fetchproxima.system.agent.configAgent → BackendRequest-reply to fetch all remote configs for an agent at startup
Command channelproxima.system.commands.{agent_id}Backend → AgentPublish-subscribe for runtime commands (config updates, future remote actions)
Agent renewalproxima.system.agent.renewAgent → BackendRequest-reply for JWT credential renewal
Config apply ackproxima.system.config.apply.{agent_id}Agent → BackendConfig apply result (success/failure per config type)

The config fetch subject uses NATS request-reply. The agent sends {agent_id} and receives a map of all config types for that agent. See Agent — Config Fetch at Startup.

The command channel is a per-agent subject that the agent subscribes to after startup. The backend publishes to it when config changes via the API. Commands use a generic envelope format with type routing. See Agent — Command Channel.

The agent renewal subject uses NATS request-reply. The agent signs its current JWT with its nkey and sends it as proof of identity. The backend validates the signature, checks the agent is active in the agents table, and issues a new JWT with the name agent-{uuid}. Legacy JWTs with host-{uuid} prefix are rejected — agents must re-enroll. If NATS is unavailable, the agent falls back to HTTPS (POST /api/v1/agents/credentials/renew).

The config apply ack subject is published by the agent after it receives and applies a config push via the command channel. The payload includes config_type (which config was applied), version (the config version), status ("success" or "failure"), and error (error message, present only on failure). The backend worker subscribes to this subject to track config application outcomes per agent.

note

All subjects are governed by per-agent user JWT permissions. Each agent can only publish/subscribe to its own agent-scoped subjects. The JWT name uses the agent-{uuid} prefix. See NATS Security for the account model and permission details.

Telemetry Subjects (per-host)

SubjectPatternDirectionDescription
Inventoryproxima.{client}.{env}.{agent_id}.inventoryAgent → BackendFull host inventory snapshot (includes labels). Only agent_type=host agents trigger host record creation.
Heartbeatproxima.{client}.{env}.{agent_id}.heartbeatAgent → BackendAgent heartbeat with uptime and labels
Metricsproxima.{client}.{env}.{agent_id}.metricsAgent → BackendSystem metrics batch
Processesproxima.{client}.{env}.{agent_id}.processesAgent → BackendFull process list snapshot
Changesproxima.{client}.{env}.{agent_id}.changesAgent → BackendFile change events (baseline + delta scans)
Logsproxima.{client}.{env}.{agent_id}.logsAgent → BackendLog entries from journald + file tailing
Kubernetesproxima.{client}.{env}.{agent_id}.kubernetesAgent/Seeder → BackendKubernetes cluster inventory (clusters, nodes, namespaces, workloads)

Where {agent_id} is the UUID from the agents table, assigned at enrollment. It is not the host_id from the hosts table. The NATS JWT for each agent is named agent-{agent_id} and its publish/subscribe permissions are scoped to this same UUID.

Alert Subjects

Added in v0.4.5

These subjects support the alerting pipeline. See Alerting & Correlation for the full architecture.

SubjectPatternDirectionDescription
Alert ingestproxima.alerts.ingestWebhook → AlertWorkerRaw alert payload from webhook receiver, published after token validation
Alert correlateproxima.alerts.correlateAlertWorker → CorrelationWorkerAlert group ID for infrastructure enrichment (metrics, changes, related alerts, compliance)

The alert ingest subject receives parsed Alertmanager payloads from the webhook handler. The AlertWorker resolves labels to Proxima entities, deduplicates alerts by fingerprint, and manages alert group lifecycle.

The alert correlate subject is published by the AlertWorker after successfully processing an alert. The CorrelationWorker queries VictoriaMetrics for metrics snapshots, PostgreSQL for recent changes and related alerts, and writes the enriched correlation context back to the alert group.

Terminal

SubjectPatternDirectionDescription
PTY outputproxima.{client}.{env}.{agent_id}.terminal.out.{session}Agent → BackendPTY output from a terminal session, streamed to browser
Terminal controlproxima.{client}.{env}.{agent_id}.terminal.ctrl.{session}Agent → BackendTerminal session control (start ack, reconnect ack)
Terminal commandsproxima.system.commands.{agent_id}Backend → AgentTerminal start/stop/detach/reconnect commands (shared with config sync and runbook dispatch)
Recording readyproxima.{client}.{env}.{agent_id}.recording.readyAgent → BackendNotification that a session recording is ready for upload
Recording fetchproxima.system.commands.{agent_id}Backend → Agentrecording_fetch command to retrieve recording file from agent
Recording deleteproxima.system.commands.{agent_id}Backend → Agentrecording_delete command to clean up local recording after upload
File transferproxima.system.file.{agent_id}.{transfer_id}BidirectionalDedicated per-transfer subject for file upload/download data
File chunksproxima.system.file.{agent_id}.{transfer_id}.chunksBackend → AgentUpload chunk data from browser to agent
File acksproxima.system.file.{agent_id}.{transfer_id}.acksBackend → AgentDownload chunk acknowledgments from browser

The PTY output subject carries raw terminal output bytes from the agent's PTY process. Each session has a unique session ID in the subject, enabling multiplexed sessions on the same host. See Terminal Access for architecture details.

The terminal commands reuse the existing per-agent command channel (also used by config sync and runbook execution). Terminal commands use the terminal_start, terminal_stop, terminal_detach, terminal_reconnect, recording_fetch, and recording_delete command types within the generic envelope format.

The file transfer subjects use a dedicated proxima.system.file.{agent_id}.> namespace, separate from the agent's publish subjects. This keeps file transfer isolated from terminal I/O and follows the principle of least privilege — the agent's NATS JWT explicitly allows subscribe on this pattern. Each transfer gets a unique subject to prevent cross-transfer interference.

Port Forwarding (Tunnel)

PurposeSubjectDirectionDescription
Tunnel commandsproxima.system.commands.{agent_id}Backend → Agenttunnel_start, tunnel_open, tunnel_close, tunnel_stop commands
Tunnel data inproxima.{client}.{env}.{agent_id}.tunnel.in.{connection_id}Backend → AgentTCP data from CLI to remote endpoint
Tunnel data outproxima.{client}.{env}.{agent_id}.tunnel.out.{connection_id}Agent → BackendTCP data from remote endpoint to CLI
Tunnel closeproxima.{client}.{env}.{agent_id}.tunnel.close.{connection_id}Agent → BackendTCP connection EOF notification
PTY exitproxima.{client}.{env}.{agent_id}.terminal.exit.{session_id}Agent → BackendPTY process exited — triggers session cleanup

Tunnel subjects follow the same per-agent scoping as terminal subjects. The tunnel.in.> pattern is explicitly allowed in the agent's NATS JWT subscribe permissions.

JetStream Streams

StreamSubjectsMax AgePurpose
EVENTSproxima.*.*.*.inventory, proxima.*.*.*.changes, proxima.*.*.*.heartbeat, proxima.*.*.*.kubernetes24 hoursInventory snapshots, change events, heartbeats, Kubernetes inventory. The fourth wildcard matches {agent_id}.
TELEMETRYproxima.*.*.*.metrics, proxima.*.*.*.processes, proxima.*.*.*.logs1 hourHigh-volume metrics, process snapshots, and log data. The fourth wildcard matches {agent_id}.
ALERTSproxima.alerts.>72 hoursAlert ingestion and correlation pipeline
note

System subjects (proxima.system.*) are not on JetStream streams. They use core NATS request-reply or plain publish-subscribe.

Consumer Groups

Consumer groups ensure each message is processed exactly once across multiple backend instances. This allows horizontal scaling of the backend without duplicate processing.

ConsumerStreamPurpose
backend-events-workerEVENTSProcesses inventory, heartbeat, and change messages
backend-metrics-workerTELEMETRYProcesses metrics, process snapshots, and log entries via TelemetryWorker → MetricsWorker / ProcessesWorker / LogsWorker
alert-workerALERTSLabel resolution, deduplication, alert grouping
correlation-workerALERTSInfrastructure enrichment (metrics snapshot, changes, related alerts, compliance)