feat(audit-logs): cache request audit log filter facets#3160
Open
bishnubista wants to merge 1 commit into
Open
feat(audit-logs): cache request audit log filter facets#3160bishnubista wants to merge 1 commit into
bishnubista wants to merge 1 commit into
Conversation
Wrap queryUniqueFilterAttributes with a cache-aside using the existing #dynamic/lib/cache abstraction (regionalCache as cache, matching d1fb2e1). Cache key includes orgId and timeStart/timeEnd bucketed to 60s boundaries with a v1 version segment. TTL 60s, per Owen's preference in fosrl#3148. Get/set failures warn and fall through; the request never 500s on cache error. Effect: dashboard refreshes within the same minute hit cache instead of re-running the six selectDistinct queries against requestAuditLog. Facet dropdowns become approximate to within ~60s; the underlying six queries are unchanged. Followup to fosrl#3148, which routed audit log reads through logsDb for replica routing in SaaS.
Contributor
Author
|
@oschwartz10612 Any thoughts? |
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.
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
Followup to #3148. As discussed in that thread, this adds a cache-aside to
queryUniqueFilterAttributesso that dashboard refreshes within the same minute don't re-run the sixselectDistinctqueries that populate the audit log filter dropdowns.Implementation:
regionalCache as cachefrom#dynamic/lib/cache, matching the dynamic pattern from d1fb2e1.cache:audit-log-facets:v1:{orgId}:{timeStartBucket}:{timeEndBucket}, with timestamps bucketed to 60s boundaries so refresh-within-the-minute hits cache. Thev1segment guards against future shape changes.logger.warn; the request never 500s on cache failure.SELECT DISTINCT LIMIT 501shape already short-circuits via hash dedup with early exit, so a query rewrite would have regressed.Branch note: this PR is based on
dev, so the file still referencesprimaryLogsDbrather thanlogsDb. #3148's routing fix landed onmain; the changes are independent and will compose cleanly when the branches sync.How to test?
npx tsc --noEmit— no new errors in the changed file (22 pre-existing errors counted before and after)./[orgId]/settings/logs/requestin the dashboard, then refresh within 60 seconds. Confirm filter dropdowns populate identically on both requests and that DB query counters don't double. Avoid testing across minute boundaries — bucket rollover would look like a miss.enable_redis: true, confirmcache.getCurrentBackend()returns"redis"for the facet keys.