Skip to content

feat: 添加prometheus和grafana支持 - #1508

Merged
h2zi merged 4 commits into
mainfrom
dev
Mar 24, 2026
Merged

feat: 添加prometheus和grafana支持#1508
h2zi merged 4 commits into
mainfrom
dev

Conversation

@h2zi

@h2zi h2zi commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Closes #

📑 Description

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have added test cases for my code
  • All the tests have passed

ℹ Additional Information

Summary by CodeRabbit

发布说明

  • 新功能
    • 添加 Grafana 应用管理:支持加载状态、查看/保存完整配置、参数调优界面、重启与配置持久化、运行状态与实时日志查看。
    • 添加 Prometheus 应用管理:支持加载状态、查看/保存主配置、全局参数调优、导出器列表与安装/卸载、导出器启停/重启、导出器配置管理及实时日志。
  • 界面
    • 新增 Grafana 与 Prometheus 管理界面与路由,采用标签页式操作并仅限管理员访问。

@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 698cb894-bec1-4038-abfc-ef61b5236dd6

📥 Commits

Reviewing files that changed from the base of the PR and between af7a756 and ef3ea14.

📒 Files selected for processing (3)
  • internal/apps/grafana/app.go
  • internal/apps/prometheus/app.go
  • web/src/views/apps/prometheus/PrometheusExportersView.vue

Walkthrough

将 Grafana 与 Prometheus 应用集成到后端与前端:新增两个应用模块(包含路由、配置读写、服务控制、导出器管理与任务调度),并将它们注册到依赖注入与应用加载器;前端新增对应 API 封装、视图与路由。

Changes

Cohort / File(s) Summary
依赖注入与引导
cmd/ace/wire_gen.go, cmd/cli/wire_gen.go, internal/apps/apps.go, internal/bootstrap/apps.go
在 Wire/Loader 中注册并注入 grafana.Appprometheus.App 实例,扩展 ProviderSet 与 NewLoader 签名。
Grafana 后端
internal/apps/grafana/app.go, internal/apps/grafana/request.go
新增 Grafana 应用及请求结构:路由、Load/配置读取与写入、INI 细粒度调优接口、INI 读写/修改辅助函数、systemd 重启控制、错误处理与绑定验证。
Prometheus 后端
internal/apps/prometheus/app.go, internal/apps/prometheus/request.go
新增 Prometheus 应用及请求结构:路由、runtime 查询、prometheus.yml 读写与 tune 接口、导出器列表/安装/卸载/启停/重启、导出器配置管理、异步任务排队用于远程脚本安装。
前端 API
web/src/api/apps/grafana/index.ts, web/src/api/apps/prometheus/index.ts
新增前端 HTTP 封装函数,覆盖加载、获取/保存配置、tune 接口及 Prometheus 导出器管理相关请求。
Grafana 前端视图与路由
web/src/views/apps/grafana/IndexView.vue, web/src/views/apps/grafana/GrafanaConfigTuneView.vue, web/src/views/apps/grafana/route.ts
新增 Grafana 管理页与参数调优视图、路由配置,包含配置编辑、保存流程与运行状态/日志面板。
Prometheus 前端视图与路由
web/src/views/apps/prometheus/IndexView.vue, web/src/views/apps/prometheus/PrometheusConfigTuneView.vue, web/src/views/apps/prometheus/PrometheusExportersView.vue, web/src/views/apps/prometheus/route.ts
新增 Prometheus 管理页、tune 视图、导出器管理视图和路由,支持导出器安装/启停/配置编辑及交互反馈。

Sequence Diagram(s)

sequenceDiagram
    participant Client as 客户端
    participant GrafanaHandler as Grafana<br/>处理器
    participant Systemctl as systemctl<br/>服务管理
    participant INIFile as grafana.ini<br/>配置文件
    participant GrafanaAPI as Grafana<br/>API端点

    Client->>GrafanaHandler: GET /apps/grafana/load
    GrafanaHandler->>Systemctl: 查询 grafana 服务状态
    Systemctl-->>GrafanaHandler: 返回状态
    alt 服务运行
        GrafanaHandler->>INIFile: 读取 server.http_port
        INIFile-->>GrafanaHandler: 返回端口
        GrafanaHandler->>GrafanaAPI: 请求 /api/health
        GrafanaAPI-->>GrafanaHandler: 返回 health
    end
    GrafanaHandler-->>Client: 返回负载信息
Loading
sequenceDiagram
    participant Client as 客户端
    participant PrometheusHandler as Prometheus<br/>处理器
    participant Systemctl as systemctl<br/>服务管理
    participant YAMLFile as prometheus.yml<br/>配置文件
    participant TaskQueue as 任务队列 (biz.TaskRepo)
    participant RemoteScript as exporter.sh<br/>远程安装脚本
    participant PrometheusAPI as Prometheus<br/>API端点

    Client->>PrometheusHandler: POST /apps/prometheus/exporters (install)
    PrometheusHandler->>TaskQueue: 创建安装任务(包含远程脚本命令)
    TaskQueue-->>RemoteScript: 执行 下载/安装 脚本(后台)
    RemoteScript-->>TaskQueue: 安装结果
    TaskQueue-->>PrometheusHandler: 任务完成/状态(异步)
    PrometheusHandler-->>Client: 返回任务已排队
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 分钟

Suggested reviewers

  • devhaozi

Poem

🐰 一只兔子的庆贺:
Grafana 与 Prometheus 牵手来,
INI 与 YAML 在夜里排舞台,
导出器装卸如拨云开,
前后端携手,监控更自在。 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰地传达了主要变更:添加Prometheus和Grafana支持。标题与所有更改的核心内容相符,简洁且信息丰富。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 415 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/apps/prometheus/app.go 0.00% 231 Missing ⚠️
internal/apps/grafana/app.go 0.00% 177 Missing ⚠️
cmd/ace/wire_gen.go 0.00% 3 Missing ⚠️
cmd/cli/wire_gen.go 0.00% 3 Missing ⚠️
internal/bootstrap/apps.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini is experiencing higher than usual traffic and was unable to create the summary. Please try again in a few hours by commenting /gemini summary.

@h2zi
h2zi merged commit 0ae7327 into main Mar 24, 2026
10 checks passed
@h2zi
h2zi deleted the dev branch March 24, 2026 14:45
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