Skip to content

feat(logs): add structured log aggregator for Docker container observability#22

Merged
dviejokfs merged 4 commits intomainfrom
feat/add-logging
Feb 28, 2026
Merged

feat(logs): add structured log aggregator for Docker container observability#22
dviejokfs merged 4 commits intomainfrom
feat/add-logging

Conversation

@dviejokfs
Copy link
Copy Markdown
Contributor

Summary

Closes #21

Adds a new temps-log-aggregator crate that provides comprehensive structured log aggregation for Docker containers deployed on the platform.

  • Real-time collection: Streams logs from Docker containers discovered via sh.temps.* labels, with reconnect resilience, container-gone detection, and bounded retries
  • Compressed storage: NDJSON chunks compressed with zstd, stored on filesystem (default) or S3
  • Dual-path search: TimescaleDB index for fast ERROR/WARN queries; archive scan with decompression for full-text search across all levels
  • Live tail: SSE streaming endpoint with project/service/level filtering
  • Retention: Configurable automatic cleanup (30d chunks, 7d events) plus manual purge with audit logging
  • Security: LogsRead / LogsDelete permission guards on all endpoints

Changes

New crate: temps-log-aggregator (8,200+ lines)

  • parser.rs — Docker JSON log parsing, plain-text level detection, structured field extraction
  • storage/ — Pluggable storage backends (filesystem, S3) with zstd compression
  • services/chunk_writer.rs — Per-container buffering with 1MB / 30s flush triggers
  • services/collector.rs — Docker log streaming with resilience (last_seen_ts tracking, container-gone detection, max consecutive errors)
  • services/metadata.rs — TimescaleDB operations for log_chunks and log_events
  • services/search.rs — Dual-path search routing (index vs archive), field filters, pagination
  • services/tail.rs — Broadcast-based live tail with filter matching
  • services/retention.rs — Chunk cleanup by age with storage deletion
  • handlers/ — HTTP endpoints: POST /logs/search, GET /logs/context, GET /logs/tail (SSE), DELETE /projects/{id}/logs
  • plugin.rs — Platform integration: startup scan, Docker events listener, retention scheduler

Modified crates

  • temps-deployer: Added labels: HashMap<String, String> to DeployRequest, applied to container creation
  • temps-deployments: Populates sh.temps.project_id, sh.temps.deployment_id, sh.temps.environment_id, sh.temps.service, sh.temps.namespace labels
  • temps-auth: Added LogsDelete permission to all 5 locations (enum, Display, from_str, all(), Role::permissions)
  • temps-entities: Added log_chunks and log_events Sea-ORM entities
  • temps-migrations: Added m20260225_000001_create_log_aggregator_tables migration
  • temps-cli: Reads TEMPS_LOG_STORAGE_BACKEND and S3 config env vars, registers plugin

Test Coverage

101 tests (was 89 before this session, +12 new):

Category Count Highlights
Parser 11 JSON/plain-text parsing, Docker timestamps, level detection
Types 7 LogLevel, LogStream, RetentionConfig, UUID determinism
Storage 12 Filesystem CRUD, S3 key construction, range reads
Chunk Writer 11 Buffering, flush, multi-container, auto-flush at 1MB, 1000-line compression roundtrip
Search 21 Service/env/deploy filtering, full-text, field filters, time ranges, 1000-line archive simulation
Tail 6 Filter matching, broadcast subscription
Metadata 4 insert_log_events_from_lines (indexable filtering), list_distinct_projects
Handlers 16 Search, context, SSE tail, purge, pagination, auth (401), permission guards (403 Reader/purge, 200 Reader/search)
Error/Plugin 4 Display formatting, plugin name

No regressions: temps-auth (102 passed), temps-deployer (39 passed)

…ollection

Implement temps-log-aggregator crate for real-time Docker container log
collection, compressed NDJSON chunk storage, full-text search, and live
tail via SSE. This provides comprehensive observability for deployed
containers on the platform.

Key features:
- Real-time Docker log streaming with automatic container discovery
- Compressed NDJSON chunk storage (zstd) on filesystem or S3
- Dual search paths: TimescaleDB index for ERROR/WARN, archive scan for full-text
- Live tail via Server-Sent Events with project/service/level filtering
- Automatic retention cleanup with configurable policies
- Permission-guarded handlers (LogsRead, LogsDelete) with audit logging

Integration points:
- Deploy containers labeled with sh.temps.* for automatic log collection
- Streaming resilience: reconnect tracking, container-gone detection, bounded retries
- Events listener with outer retry loop for permanent liveness
- Plugin registered in console.rs with configurable storage backend

Test coverage: 101 tests (unit + integration) covering parser, storage,
chunk writer, search, tail, metadata, handlers, permissions, compression
roundtrips, and large batch scenarios.
…log history UI

- Refactor log aggregator from UUID to i32 project_id throughout the entire
  write and read path (collector, chunk writer, metadata, search, storage keys)
- Remove unused log_events table and TimescaleDB hypertable dependency
- Fix BuildKit build log output: emit vertex names (build step descriptions)
  in addition to command output, so cached layers are visible
- Revert tar context creation to file-based spawn_blocking approach
- Restore temps-environments, temps-screenshots, temps-embeddings in workspace
- Consolidate migrations into single m20260225_000001
- Add frontend log history viewer with filters, pagination, and virtualized rendering
- Add History tab to project runtime logs page
- Introduced a new `_typos.toml` file to extend words with the `flate2` crate.
- Updated `.gitignore` to include `.env`, `.env.local`, and `content/` directories.
- Enabled `cargo clippy` pre-commit hook in `.pre-commit-config.yaml` for linting Rust code.
- Updated `Cargo.lock` with new dependencies including `fixedbitset`, `multimap`, `petgraph`, and `prost-build`.
- Added `temps-otel`, `temps-plugin-sdk`, and `temps-external-plugins` crates to the workspace in `Cargo.toml`.
- Enhanced `CHANGELOG.md` with new features and improvements related to OpenTelemetry and plugin systems.
…ory viewer

- Added `temps-log-aggregator` crate for real-time Docker container log collection with features like automatic container discovery, compressed NDJSON storage, dual search paths, and live tail via Server-Sent Events.
- Implemented a frontend log history viewer with search filters, pagination, and virtualized rendering, accessible through a new History tab in the project runtime logs page.
- Upgraded Bollard to 0.20.1, migrating all crates to the new API.
- Enhanced BuildKit log output to include vertex names for better visibility in deployment logs.
@dviejokfs dviejokfs merged commit 921ab97 into main Feb 28, 2026
9 checks passed
@dviejokfs dviejokfs deleted the feat/add-logging branch April 3, 2026 06:50
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.

feat: Structured log aggregator for Docker container observability

1 participant