Skip to content

perf(agent): pattern/service catalog lists - #321

Merged
hoalongnatsu merged 1 commit into
mainfrom
feature/update
Aug 3, 2026
Merged

perf(agent): pattern/service catalog lists#321
hoalongnatsu merged 1 commit into
mainfrom
feature/update

Conversation

@hoalongnatsu

Copy link
Copy Markdown
Member

What does this PR do?

Adds server-side pagination to the agent catalog list endpoints (GET /api/agent/patterns, GET /api/agent/services) so they serve a bounded page plus a cheap total count instead of materializing the whole catalog on every request. Brings these two lists onto the same pattern the incidents/analyses lists already use.

Why?

On the Postgres backend, listPatterns/listServices went through catalog.Snapshot() — an unbounded SELECT over vs_patterns/vs_services plus a full JSON serialize and per-row readiness compute on every list load. This is the catalog twin of the incidents/analyses pagination already shipped. No linked issue — internal perf follow-up.

How to test

  1. Run OSS with STORAGE_TYPE=postgres and generate enough varied logs across many services to learn more patterns/services than one page (or pass a small page_size).
  2. GET /api/agent/patterns?page_size=5 → 5 rows, total = whole-catalog count, next_offset set on a full page; walk offset/page → non-overlapping, stable, gap-free windows; next_offset null on the last underfull page.
  3. ?q=<substring> filters server-side (smaller total); re-fetching a page is deterministic (patterns fleet-count desc→id; services first_seen→name).
  4. GET /api/agent/services?page_size=5 → paged envelope; services stays a name→facts map with grace fields; total = whole set.
  5. page_size clamps to [1,5000] (default 1000); negative offset → 0.
  6. UI Patterns/Services pages: header shows the whole-set total, Load more appends the next page, table sort works on loaded rows.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (config / API / default behavior)
  • Documentation only
  • Refactor (no functional change)
  • CI / build / chore

Checklist

  • go test versus passes locally
  • go vet versus is clean
  • Code is gofmt
  • Added or updated tests for the change
  • Updated user-facing docs under src/ if behavior changes (internal admin API; no src/ doc change)
  • Updated ROADMAP.md if this closes a roadmap item
  • No secrets, tokens, or webhook URLs introduced in source / YAML
  • No new third-party dependencies (or justified in the description)

@hoalongnatsu
hoalongnatsu merged commit adbf2c0 into main Aug 3, 2026
7 checks passed
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