Skip to content

feat: Data persistence with DuckDB for historical analysis #9

@rlaope

Description

@rlaope

Problem

Currently, Argus stores events only in memory with limited buffer size (65,536 events). When the buffer fills up or the application restarts:

  • Historical data is lost
  • Cannot analyze patterns over time
  • No way to compare performance across sessions

Proposed Solution

Integrate DuckDB (embedded analytical database) for event persistence:

  1. Store all events to local DuckDB file
  2. Enable time-range queries for historical analysis
  3. Support data retention policies
  4. Allow export to Parquet files for external analysis

Acceptance Criteria

  • Add DuckDB dependency to argus-server
  • Create schema for virtual thread events
  • Persist events asynchronously (non-blocking)
  • Add /history API endpoint with time-range filtering
  • Implement data retention (configurable, default 7 days)
  • Add dashboard section for historical trends
  • Support -Dargus.persistence.enabled=true flag

Technical Considerations

  • DuckDB is embedded (no external server needed)
  • Use batch inserts for performance (every 1000 events or 1 second)
  • Consider WAL mode for durability vs performance trade-off
  • File location: ~/.argus/data/events.duckdb

Schema Design

CREATE TABLE virtual_thread_events (
    id BIGINT PRIMARY KEY,
    timestamp TIMESTAMP,
    event_type VARCHAR(32),
    thread_id BIGINT,
    thread_name VARCHAR(256),
    carrier_thread BIGINT,
    stack_trace TEXT,
    duration_ns BIGINT
);

CREATE INDEX idx_timestamp ON virtual_thread_events(timestamp);
CREATE INDEX idx_thread_id ON virtual_thread_events(thread_id);
CREATE INDEX idx_event_type ON virtual_thread_events(event_type);

API Design

GET /history?from=2024-01-01T00:00:00Z&to=2024-01-02T00:00:00Z&type=PINNED

{
  "query": { "from": "...", "to": "...", "type": "PINNED" },
  "totalEvents": 15234,
  "events": [ ... ]
}

Configuration

argus.persistence.enabled=true
argus.persistence.path=~/.argus/data
argus.persistence.retention-days=7
argus.persistence.batch-size=1000

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions