feat: add pulse stats and pulse diff commands - #1
Merged
Conversation
Adds `pulse stats --since <window>` (per-container restart counts, status transitions, and uptime resets) and `pulse diff --since <window>` (appeared/ disappeared/changed-image/restarted containers vs. a point in the past). Both are backed by two new CLIService RPCs (GetContainerStats, DiffContainers) computed from data Pulse already tracks: the containers table's created_at/removed_at lifecycle timestamps and the container_events hypertable's status/uptime history. No agent or schema changes needed. Also introduces a "default node" concept (PULSE_DEFAULT_NODE env var or default-node in ~/.pulse/config.yaml, falling back to auto-selecting the sole registered node) so --node can be omitted on these commands.
Signed-off-by: ipedrazas <ipedrazas@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pulse stats --node X --since 24h [--json]— per-container restart counts, status transitions, and uptime resets over a lookback window.pulse diff --since 2h [--node X] [--json]— compares current container state against a point in the past: appeared, disappeared, changed-image, and restarted containers.CLIServiceRPCs,GetContainerStatsandDiffContainers, computed entirely from data Pulse already persists — no agent (Rust) changes or DB migrations required:containers.created_at/removed_atgive the "was this container alive at time T" signal used for the diff's before/after snapshots.container_eventshypertable'sstatus/uptime_secondshistory gives status transitions and uptime resets (a drop inuptime_secondsbetween consecutive samples = a restart).--nodecan be omitted: resolution order is--nodeflag →PULSE_DEFAULT_NODEenv var →default-nodein~/.pulse/config.yaml→ the sole registered node if there's exactly one → a clear error otherwise.--sinceusestime.ParseDuration(24h,2h,30m, ...) with a helpful error on invalid input;diffrequires it,statsdefaults to24h.Design note: "changed image digest"
Pulse doesn't currently track image digests anywhere (agent, proto, or DB) — only the image reference string (e.g.
nginx:latest). Docker containers are also immutable with respect to their image: changing a container's image always means recreating it (a new container ID), never an in-place field update. Sochanged_imageis detected by matching containers by name across the window and comparing the image reference on the container that's actually running now vs. what was running before — the same mechanism that also flags a same-name container recreation asrestarted. This matches the spec's intent ("still running, but different image") without inventing digest telemetry that doesn't exist in the system today.Test plan
buf lint/buf generate— proto changes are lint-clean and generate without errorgo buildfor API and CLIgo test— API unit tests, CLI tests, and new Testcontainers-backed integration tests (TestListContainersAt,TestListContainerEvents,TestGetContainerStats,TestDiffContainers) all pass against real TimescaleDBgovulncheck— no new findings vs.main(5 pre-existing dependency vulnerabilities onmainunrelated to this change, from a vuln DB update sincemain's last CI run)pulsebinary — verifiedpulse ps,pulse stats,pulse diff(table and--json), default-node auto-resolution, and error paths (invalid--since, missing--since, unreachable node, empty window)