Skip to content

[logger] Add in-memory log storage with web UI - #1285

Merged
manugarg merged 8 commits into
mainfrom
add-log-store-core
Apr 9, 2026
Merged

manugarg merged 8 commits into
mainfrom
add-log-store-core

Conversation

@manugarg

@manugarg manugarg commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add per-source in-memory log storage with configurable memory ceiling (--log_store_max_mem_mb, default 50MB)
  • Integrate with existing logger package — all probe and component logs captured automatically, zero probe code changes
  • Expose logs via web UI at /logs with HTML and JSON (/logs?format=json) views

Details

New package logger/logstore: Per-source ring buffers (keyed by probe name or component name) backed by a total memory ceiling. When the ceiling is hit, oldest entries are evicted from the buffer using the most memory.

Logger integration: logStore field added to Logger, auto-attached via atomic.Pointer-based global default. logAttrs() writes to the store after stderr output. All loggers created after SetDefaultLogStore() capture logs automatically.

Web UI: /logs endpoint with source dropdown (populated from data), auto-submit filters, color-coded log levels, and JSON output support.

Flags:

  • --log_store_max_mem_mb (default 50, 0 to disable)
  • --log_store_min_level (default INFO)

Test plan

  • go test ./logger/logstore/... — ring buffer, memory ceiling, concurrent access, query filtering
  • go test ./logger/... — logger integration
  • go test ./web/... — web handler
  • go build ./... — full build passes
  • Manual: run cloudprober, visit /logs, verify logs appear

Add a log store that captures probe and component log messages in
memory with a configurable memory ceiling (--log_store_max_mem_mb,
default 50MB). The store integrates with the existing logger package
so all logs are captured automatically without any probe code changes.

Key components:
- logger/logstore: Per-source ring buffers with memory-ceiling eviction
- logger.SetDefaultLogStore: Thread-safe global store (atomic.Pointer)
- logger.ParseLogLevel: Shared log level parser
- /logs web endpoint with HTML and JSON views, auto-submit filters,
  source dropdown, and color-coded log levels

Flags:
- --log_store_max_mem_mb (default 50, 0 to disable)
- --log_store_min_level (default INFO)
manugarg added 2 commits April 7, 2026 23:49
Instead of scanning all buffers on every write once the store is full,
allow up to 5% overshoot and evict down to 95% of the ceiling when
triggered. This amortizes the O(num_sources) eviction scan over many
writes — e.g., ~25K free writes between scans for a 50MB store.
@manugarg manugarg changed the title Add in-memory log storage with web UI [logger] Add in-memory log storage with web UI Apr 8, 2026
@manugarg
manugarg force-pushed the add-log-store-core branch 4 times, most recently from 175db24 to a76454a Compare April 8, 2026 18:28
manugarg added 3 commits April 8, 2026 11:36
Cache /logs page responses for 5 seconds, keyed by full URL
(including query params). Add tests for web/logs handler and
improve logstore test coverage from 91% to 98%.
@manugarg
manugarg force-pushed the add-log-store-core branch from e69d6ce to 30e8214 Compare April 9, 2026 00:00
@manugarg

manugarg commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author
logs_screenshot

@manugarg
manugarg merged commit 6837ea4 into main Apr 9, 2026
12 checks passed
@manugarg
manugarg deleted the add-log-store-core branch April 9, 2026 01:52
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