feat(console): 增加 Usage/Audit Dashboard BFF#2016
Merged
Merged
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
730c9ad to
efb5452
Compare
PR Code Suggestions ✨No code suggestions found for the PR. |
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.
Description
WIP:本 PR 为 Console 增加内置在 OV Server 内的 Usage/Audit BFF 能力,用于支撑 Console 首页和请求日志类产品化数据展示。
核心思路是复用现有 metrics/observability 打点链路,把同一份请求、模型、检索信号分发给 metrics 和 Usage/Audit 两类消费者:metrics 继续面向 Prometheus/运维观测,Usage/Audit 负责产品侧可查询、可聚合、可持久化的数据。
当前版本先落地本地版 SQLite store,并保留
UsageAuditStore抽象,后续生产环境可以扩展到 Postgres、ClickHouse 或其他服务端存储。Related Issue
暂无关联 Issue。
Type of Change
Changes Made
GET /api/v1/console/dashboard/summaryGET /api/v1/console/tokensGET /api/v1/console/context-commitsGET /api/v1/console/auditopenviking.observability.events进程内事件总线,metrics datasource 通过共享事件总线发布事件,metrics collector 和 Usage/Audit subscriber 可以消费同一份信号,避免重复打点。openviking.observability.usage_audit模块:/api/v1/search/find和/api/v1/search/search请求事件VikingFS.stat().count读取业务目录当前状态,不再直接 count vector store,也不通过历史写入事件累计/ov/console/...转发,避免 wildcard proxy 带来的路径穿越风险。observability.usage_audit配置,默认启用 SQLite 本地存储。docs/design/console-usage-audit-design.mdopenviking/observability/usage_audit/README.mdTesting
本地验证命令:
结果:
28 passed另外,本地启动 OV Server 后做过一轮接口级验证,包括创建 session、写入 messages、调用 search/find、查询
/api/v1/console/*BFF 接口。验证记录写在本地忽略文件test_scripts/usage-audit-live-api-run.md,未纳入 PR,避免提交一次性运行产物。Checklist
Screenshots (if applicable)
不适用。本 PR 主要是 OV Server BFF、Usage/Audit 存储和后端聚合逻辑。
Additional Notes
ContextInventoryProvider使用VikingFS.stat().count读取当前状态;业务根目录不存在时按 0 处理,非预期异常记录 warning 后降级为 0。git commit的 pre-commit hook 因环境缺少pre_commit模块未能执行,已手动完成 ruff 和 pytest 验证后使用--no-verify提交。